Skip to content
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

Google Search Console "Reference to non-existent item" #53

Open
dw-herrmann opened this issue Apr 21, 2022 · 8 comments · May be fixed by #69
Open

Google Search Console "Reference to non-existent item" #53

dw-herrmann opened this issue Apr 21, 2022 · 8 comments · May be fixed by #69

Comments

@dw-herrmann
Copy link

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!

@marc22761
Copy link

I'm having the same issue.

@lexislav
Copy link

I am also having this issue. Is it possible to customize meta knight template and remove this line?

@afbora
Copy link

afbora commented Aug 8, 2022

@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,
],

@Messa1
Copy link

Messa1 commented Aug 17, 2022

Any Update?

@Jayshua
Copy link

Jayshua commented Nov 15, 2022

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.

@renestalder
Copy link

Could we get that in a PR?

@Jayshua
Copy link

Jayshua commented Dec 22, 2022

@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.

renestalder added a commit to renestalder/kirby-meta-knight that referenced this issue Dec 23, 2022
Fixes Google Search Console "Reference to non-existent item" error when
trying to index a website that does not have a meta image set

fixes diesdasdigital#53

Co-authored-by: Jayshua Nelson <[email protected]>
@renestalder
Copy link

There you go:
#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

7 participants