Ok so now its the future and the Meta Tags Plugin has been updated for Kirby 2.5.7 which has meant some slight changes to the syntax it uses because I found an issue.
Heres the updated version of the fallback above, using the new syntax, in case its useful to somebody.
// SEO Settings
// Global
c::set('meta-tags.default', function(Page $page, Site $site) {
return [
'title' => $page->isHomePage()
? $site->seotitle()
: $page->seotitle().' | '.$site->seotitle(),
'meta' => [
'robots' => 'index,follow,noodp',
'description' => $page->isHomePage()
? $site->seometa()
: $page->seometa(),
'keywords' => $page->isHomePage()
? $site->seokeywords()
: $page->seokeywords(),
'robots' => 'index,follow,noodp',
],
'link' => [
'canonical' => $page->url()
],
'og' => [
'title' => $page->isHomePage()
? $site->seotitle()
: $page->seotitle().' | '.$site->seotitle(),
'type' => 'website',
'site_name' => $site->title(),
'url' => $page->url(),
'image' => function($page) {
$image = $page->shareimage()->toFile();
if($image) {
return $image->focusCrop(1200, 630)->url();
} else {
$image = site()->shareimage()->toFile();
if($image) {
return $image->url();
} else {
$image = new Asset('assets/images/fallback.png');
return $image->url();
}
}
},
'description' => $page->isHomePage()
? $site->seometa()
: $page->seometa().' | '.$site->seotitle(),
],
'twitter' => [
'title' => $page->isHomePage()
? $site->seotitle()
: $page->seotitle().' | '.$site->seotitle(),
'card' => 'summary',
'site' => $site->twitterusername(),
'creator' => $site->twitterhandle(),
'image' => function($page) {
$image = $page->shareimage()->toFile();
if($image) {
return $image->focusCrop(800, 400)->url();
} else {
$image = site()->shareimage()->toFile();
if($image) {
return $image->url();
} else {
$image = new Asset('assets/images/fallback.png');
return $image->url();
}
}
},
'url' => $page->url(),
'description' => $page->isHomePage()
? $site->seometa()
: $page->seometa().' | '.$site->seotitle(),
]
];
});
// Specific Pages
c::set('meta-tags.templates', function(Page $page, Site $site) {
return [
'newsarticle' => [
'og' => [
'type' => 'article',
],
'twitter' => [
'card' => 'summary_large_image',
'image' => function($page) {
$image = $page->shareimage()->toFile();
if($image) {
return $image->focusCrop(800, 400)->url();
} else {
$image = site()->shareimage()->toFile();
if($image) {
return $image->url();
} else {
$image = new Asset('assets/images/fallback.png');
return $image->url();
}
}
},
],
],
];
});