Skip to content

Instantly share code, notes, and snippets.

@lumpysimon
Last active July 10, 2018 14:10
Show Gist options
  • Save lumpysimon/37fd1e4931979bf82714f93335842c22 to your computer and use it in GitHub Desktop.
Save lumpysimon/37fd1e4931979bf82714f93335842c22 to your computer and use it in GitHub Desktop.
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