Open dw-herrmann opened 2 years ago
I'm having the same issue.
I am also having this issue. Is it possible to customize meta knight template and remove this line?
@jonathanmuth We are experiencing this issue with several of our customers. What do you think about getting rid of this line or putting a custom option for this? I can create a PR if you see fit 👍
'diesdasdigital.meta-knight' => [
'websiteItemscope' => false,
],
Any Update?
Here's a full explanation of what's going on for anyone who is interested. A quick fix is at the end.
<style itemscope itemtype="https://schema.org/WebSite" itemref="schema_name schema_description schema_image"></style>
is meant to describe info about the web site so that Google & other tools can extract the name, description and a representative image of the website for machine use. (Like generating those special cards that show up in Google searches sometimes, or inserting a picture when you send a link to someone in Messenger, WhatsApp, Telegram, etc.)
Don't get too hung up on it being a <style>
tag. It could be any tag, I'm not sure why MetaKnight decided to use a <style>
tag. I probably would have used a <meta>
tag.
itemscope means "I'm describing something with structured data here. Look for sets of key-value pairs describing this thing." E.g., you might have something like: <div itemscope itemtype="https://schema.org/Movie"><p>Director: <span itemprop="director">Alfred Hitchcock</span></p></div>
to describe a movie. The itemprop attribute indicates the property from the itemtype schema the element is describing.
itemtype indicates the type of thing being described. Here it's a website. It could be "https://schema.org/Movie" to describe a movie, in which case tools would be looking for attributes like "director" or "actor". You can visit https://schema.org/WebSite to see the full set of attributes that are supported for WebSites. Technically you could put your own schema here, but it's only useful if the other machines you are trying to communicate with understand what you're describing, so in practice it pretty much always points to something on the schema.org domain.
itemref permits defining props describing your thing elsewhere in the document. (Normally props describing your thing need to be descendants of the element using the itemscope attribute.) It's a space separated list of ids to look for to find more props.
That brings us to this bug. <style itemscope itemtype="https://schema.org/WebSite" itemref="schema_name schema_description schema_image"></style>
is trying to provide information about your website (to Google, Bing, Facebook, etc.) It says "I'm describing a WebSite, find elements with the ids "schema_name, schema_description and schema_image" for more info.
You'll probably find a meta tag like this nearby in the source: <meta id="schema_name" itemprop="name" content="...">
This tag is providing data for the name
property defined in https://schema.org/WebSite.
There's probably a meta tag with the id "schema_description" and the itemprop "description" nearby as well.
There's probably not a tag with the id "schema_image" in your source, since the default meta_information
snippet provided by MetaKnight only produces that element if you define a meta_image field on the page or site.
The correct fix is to only include the schema_image
id in the itemref
list if there is actually an element with the schema_image
id on the page.
You probably do not want to remove the <style itemscope...
line altogether, since that would make bots unable to extract useful info about your website.
A quick fix is to copy the kirby-meta-knight/snippets/meta_information.php
file into your site/snippets
folder and replace this line:
<style itemscope itemtype="https://schema.org/WebSite" itemref="schema_name schema_description schema_image"></style>
With this:
<style itemscope itemtype="https://schema.org/WebSite" itemref="schema_name schema_description <?= ($page->meta_image()->toFile() ?? $site->meta_image()->toFile()) ? 'schema_image' : null ?>"></style>
This will only include the schema_image id in the itemref id list if there's actually a schema_image to find.
Could we get that in a PR?
@renestalder I don't submit PRs without confirmation from the maintainer that they want the change/fix. It just wastes time if they want to go in a different direction with the code. If you'd like to take the time to do it though, be my guest.
There you go: https://github.com/diesdasdigital/kirby-meta-knight/pull/69
@Jayshua I hope it's okay I've set you as co-author in the commit because I basically did nothing else than verifying your patch and putting it in a PR. It's you that did the work.
Hi there,
my kirby site, in which meta knignt, creates an error in Google Search Console.
<style itemscope itemtype="https://schema.org/WebSite" itemref="schema_name schema_description schema_image"></style>
creates the error "Unparsable structured data/Reference to non-existent item".How can I or meta knight fix this problem? By research, I didn't quite understand it.
Thanks in advance!