Pergunta

I'm having trouble figuring out if I've done things right with RDFa and the schema.org Blog type. My blog used to have a list of posts that looked like this:

<h2><a href="essays/why-orm-divides-us.html">Why ORM Divides Us</a></h2>
<h2><a href="essays/heretic-calculus.html">A Heretical Calculus</a></h2>

In trying to augment it with RDFa information, specifically the Blog and BlogPosting types, I have come up with this:

<div vocab="http://schema.org/" typeof="Blog">
  <h2 property="blogPosting" typeof="BlogPosting" resource="essays/why-orm-divides-us.html">
    <a property="url" href="essays/why-orm-divides-us.html">
      <span property="name">Why ORM Divides Us</span>
    </a>
  </h2>
  <h2 property="blogPosting" typeof="BlogPosting" resource="essays/heretic-calculus.html">
    <a property="url" href="essays/heretic-calculus.html">
      <span property="name">A Heretical Calculus</span>
    </a>
  </h2>
  ...

As far as I can tell with Google Rich Snippets Testing Tool, this looks like it parses right, but I can't really tell. I have two other tries:

<div vocab="http://schema.org/" typeof="Blog">
  <h2 property="blogPosting" typeof="BlogPosting" resource="essays/why-orm-divides-us.html">
    <a href="essays/why-orm-divides-us.html" property="name">Why ORM Divides Us</a>
  </h2>
  <h2 property="blogPosting" typeof="BlogPosting" resource="essays/heretic-calculus.html">
    <a href="essays/heretic-calculus.html" property="name">A Heretical Calculus</a>
  </h2>
  ...

<div vocab="http://schema.org/" typeof="Blog" rel="blogPosting">
  <h2 typeof="BlogPosting" resource="essays/why-orm-divides-us.html">
    <a property="url" href="essays/why-orm-divides-us.html">
      <span property="name">Why ORM Divides Us</span>
    </a>
  </h2>
  <h2 typeof="BlogPosting" resource="essays/heretic-calculus.html">
    <a property="url" href="essays/heretic-calculus.html">
      <span property="name">A Heretical Calculus</span>
    </a>
  </h2>
  ...

So I'm asking for several pieces of information:

  1. How do you tell if you've achieved conformance with one of these schemas?
  2. Which one of my alternatives is right, and why?
  3. Why do I seem to need to specify the resource directly when I'm on a link?
  4. Why does the <a> tag parse so differently in the RDFa demo tool and the Google Rich Snippets Testing Tool?
Foi útil?

Solução

Your first snippet is correct and I'd recommend to use it. The second one is incorrect, as the property="name" will target the href value, so don't use that one. The third one is also correct, and uses a more advanced feature of RDFa called chaining (via the rel attribute). It's perfectly valid to use that one if you prefer, Google understands it too.

  1. I'm not aware of any official schema.org validator, but Google Rich Snippet will sometimes tell you if something is wrong (not always though). You can also validate your HTML + RDFa markup with http://validator.w3.org/nu/ and http://www.w3.org/2012/pyRdfa/Validator.html.
  2. your first and third are correct, the second one is wrong (see above). I'd recommend the first one.
  3. well, the url of the link is used for two purposes, first it is used to identify you object on the web, and it's also explicitly used for the 'url' property that schema.org requires. Although the second is a schema.org specific property.
  4. That's something that Google adds on top of the RDFa syntax itself, a pure RDFa parser would not return the value and href grouped like that. I guess Google does that for convenience, but I agree it can possibly be confusing.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top