Set a different homepage title

Setting the HTML title tag with Kirby is easy.
You can use the site wide $site->title() in connection with the title of the current page $page->title to generate something pretty decent:

<title><?= html($site->title() . ' – ' . $page->title()) ?></title>

…or…

<title><?= html($page->title() . ' | ' . $site->title()) ?></title>

…just however you prefer.

But what if you want to have a very descriptive title for your homepage or just the site title, without adding an extra template for it?

Kirby has the built-in $page->isHomepage() function, which makes it fairly simple to change your title only on the homepage:

<?php if($page->isHomepage()): ?>
<title>Welcome to my fantastic, awesome, little website</title>
<?php else: ?>
<title><?= html($site->title() . ' – ' . $page->title()) ?></title>
<?php endif ?>

…or maybe just…

<?php if($page->isHomepage()): ?>
<title><?= html($site->title()) ?></title>
<?php else: ?>
<title><?= html($site->title() . ' – ' . $page->title()) ?></title>
<?php endif ?>