HowTo: Use custom Snippet-Description based on theme
mountbatt opened this issue · comments
Hi,
how can I set a custom "description" for example on a page that has the theme/blueprint "event-article"?
I want to show the event_date and event_location in the snippet and I want to do this automatically, cause the editors on the website wont enter these informations into the snippet-fields by hand …
Cheers,
Tobias
Using a page model, you can set meta data programatically like this:
<?php
class EventArticlePage extends Page
{
/**
* Programmatic SEO defaults
*/
public function metaDefaults()
{
return [
'metaDescription' => $this->text()->excerpt(160),
'fieldName' => 'blabla',
];
}
}
Thanks. Thats super nice!