1

I've a problem with validation of the code provided by Google. Idea is (simplified):

<head itemscope itemtype="http://schema.org/WebSite">
  <title itemprop="name">Example.com - Best Website in the World</title>
  <meta name="description" content="Blah Blah Blah" itemprop="description">
  <link rel="canonical" href="https://example.com/" itemprop="url">
</head>

Inspired by Google documentation (see markup example).

The main problem is that the code above isn't valid:

Attribute itemprop not allowed on element meta at this point.
Attribute itemprop not allowed on element link at this point.

But if I remove itemprop, Google Structure Tool no longer recognizes the url and description as properties.

Please tell me why is that, I mean why does Google provide non-valid code and how can I solve this?

1

The example is invalid HTML+Microdata. It is not allowed to have the itemprop attribute on meta[name] or link[rel] elements.

The solution for HTML+Microdata would be to duplicate the elements:

<head itemscope itemtype="http://schema.org/WebSite">
  <title itemprop="name">Example.com - Best Website in the World</title>
  <meta name="description" content="Blah Blah Blah">
  <meta itemprop="description" content="Blah Blah Blah">
  <link rel="canonical" href="https://example.com/">
  <link itemprop="url" href="https://example.com/">
</head>

With HTML+RDFa, it’s possible to mix:

<head typeof="schema:WebSite">
  <title property="schema:name">Example.com - Best Website in the World</title>
  <meta name="description" property="schema:description" content="Blah Blah Blah">
  <link rel="canonical" property="schema:url" href="https://example.com/">
</head>
  • This helps, thank you! Advice me please, do you recommend to use Microdata or RDFa? – Mike Mar 9 '17 at 22:47
  • 1
    @Mike: I prefer RDFa, and I typically recommend RDFa -- but without knowing more about your case, such a recommendation wouldn’t mean much, of course. -- See my answer to our question Microdata vs RFDa (or the more detailed version on Stack Overflow) – unor Mar 10 '17 at 0:35
  • Excuse me, can you point me to the education material, please, where I can read about usage of prefix inside the typeof property? I see it's working, but I've just read RDFa Lite spec at W3C and they say I can use predefined prefixes when I assign second vocabulary via prefixes but they didn't mention that I can omit vocab property and use the prefixes right inside the typeof. So I'm a bit lost and don't know what's is the right way - should I use vocab or prefixes like you did in the example above? Thank you. – Mike Mar 10 '17 at 21:49
  • And in your RDFa example the url property doesn't recognized by Google Structure Tool, even though it's valid, yeah. But it works only if I add second link with this property. – Mike Mar 10 '17 at 22:25
  • @Mike: There are several ways how terms can be specified in RDFa. I gave three examples in another answer. In this answer here I made use of the RDFa Core Initial Context (not necessarily the best practice; if you are comfortable with RDFa and don’t mind the additional markup, I would always explicitly specify the vocabulary with prefix). – unor Mar 11 '17 at 1:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.