Instantly share code, notes, and snippets.

@lumpysimon lumpysimon/meta-tags.php
Last active Jul 10, 2018

Embed
What would you like to do?
Kirby meta tags config file
<?php
c::set('meta-tags.default', function(Page $page, Site $site) {
if ( $page->isErrorPage() )
return [
'title' => $page->title()
];
$title = ( $page->isHomePage() ? $site->title() : $page->title() . ' - ' . $site->title() );
return [
'title' => $title,
'meta' => [
'description' => $page->isHomePage() ? $site->description() : $page->description()
],
'link' => [
'canonical' => $page->url()
],
'og' => [
'title' => $title,
'type' => 'website',
'site_name' => $site->title(),
'url' => $page->url(),
'namespace:image' => function(Page $page) {
$image = $page->seoimage()->toFile();
return [
'image' => $image->url(),
'height' => $image->height(),
'width' => $image->width(),
'type' => $image->mime()
];
}
],
'twitter' => [
'card' => 'summary_large_image',
'site' => $site->twitter(),
'creator' => $site->twitter()
]
];
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment