-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REQUEST: Define a fallback page field for description. #14
Comments
This is something I mentioned in Issue diesdasdigital#14, and I ended up adding these changes to my own site. I'm putting it in as a PR just in case you think it would help you as well. So basically, what this does in a nutshell is add an excerpt of page->text() as a fallback between manually enterered meta info and the sitewide meta info. So, for example, OpenGraph looks like... 1. OpenGraph Description 2. Meta Description 3. Excerpt of Page Text 4. Sitewide Meta Description 5. blank/error message If this is unhelpful or not what you were thinking for this plugin, do please ignore. Just providing what I did in case it helps others.
Thanks for your feedback. This is a very interesting idea. I'll look into adding it as a config option. The one thing I am worried about is that fallbacks aren't self-explanatory. I need to come up with a better way of communicating where the plugin is pulling the fall back information from. Maybe a small label in the preview section? |
I'd like to extend this request to all fields, not just "Description". The ability to be able to pull information automatically from other fields on the page is pretty essential. A typical use-case is when a site has a Blog with Article pages. In general, the Article page will already have:
We don't really want to have to ask the client to enter all that information twice, in different places. Specially for small-business clients, who have to do everything themselves, we want to keep work to a minimum. Ideally, we would love to be able to setup the Meta Knight fields so they would take precedence over the 'default' fields on the page - i.e., if the client does enter something in the Meta Knight 'Description' field, then that would be used in preference over what's been entered in the 'Teaser' field for the article. This would give clients that have an 'SEO Expert' working with them the ability to 'override' the metadata defaults if they want, while not having to do so for every single Article page. A possible way to make it work would be to setup 'default' field values directly in the page's blueprint:
Then, when outputting the metadata fields in the template, the method would:
|
@iocouto Thank you so much for thinking this through and coming up with a possible solution. You are absolutely right, nobody wants to enter the same information twice. Would be great if we can find a way to setup default fields via a page's blueprint. While this shouldn't be too difficult to implement in the template, I'd also like to display the 'default' field values in the SEO tab's previews. Not 100% sure how I would do that. I'll need some time to think it through. Any help is appreciated. |
What about setting up fallback order in 'diesdasdigital.meta-knight' => [
'fallbackFields' => [
'description' => [
'page_description',
'summary'
'text',
],
'image' => [
'hero'
'pic',
]
]
] So this is saying... "if you don't have a meta description for this page, see if there's something in Similarly, check |
hi all, sorry if i didnt read all comments, but maybe storing the defaults from the site.yml? not sure if that helps with the previews. right now i have a tab for default seo in my site.yml and then each page has the same tab. and then in the templates i just check if the page has SEO data, if not, i call the site data. i know its a bit different than the defaults ahoy is talking about, but i think this would be the lowest level of default as a fail safe |
This would be really helpful. I have looked into it a little and I really like the suggestion of @iocouto to define the fallbacks on a blueprint/template base. In PHP it should be something like As for the VUE part, looking at the network tab shows that the blueprint data is part of the data request too. I wanted to tinker around a bit, but I encountered some postcss8 error when building. Anyway, @jonathanmuth is this somewhere on you list in the coming months or are you busy? If busy, I can have a go at it if time permits, as I am currently quite busy as well, but I think this feature would save a lot of time for future clients so there is a good reason to squeeze it in :) |
This would be a really great feature and as I cannot develop it by my own I can help you testing it on my 3.6 alpha test environment for my personal blog. |
Is there any workaround for this in the meanwhile? |
@MaluNoPeleke Have a look at https://github.com/jonaskuske/kirby-meta-knight/blob/docs/source-seo-from-content/README.md#sourcing-seo-data-from-existing-page-content :) TL;DR: <?php // site/models/default.php
class DefaultPage extends Page {
public function meta_description() {
return parent::meta_description()->or($your_fallback_here);
}
} |
Hiya! I was just checking out MetaKnight and I really like it, but there's one specific thing keeping me from adopting it for sites right now.
The way that I built my own fallbacks is that it looks for the meta description, but if it can't find one it looks for
$page->text()
.If it finds
$page->text()
, then it'll trim the first 180 characters of that, and turn that into the page description.But if it can't find that, it'll just use the backup site meta instead.
Obviously every Kirby site is gonna be built differently, but do you think it would be possible to implement configs for fallbacks before it goes to site description?
I can PR some changes to
meta_information.php
if you like.The text was updated successfully, but these errors were encountered: