3

I'm creating a site about an author. He is the main-topic. On this site his written books are shown, too.

Unfortunately, I can't find a solution to link these books to the main person-element. I tried itemref, but it doesn't work when linking to such 'independent' element, which has no itemprop value (says the Google testing tool). Both following "book"-cases don't work.

<div id="author" itemscope="" itemtype="http://schema.org/Person">
  <span itemprop="name">Marvin</span>
</div>

<div itemscope="" itemtype="http://schema.org/Book">
  <span itemprop="name">Nice Book</span>
  <meta itemprop="author" itemref="author" />
</div>

<div itemscope="" itemtype="http://schema.org/Book">
  <span itemprop="name">Best Book</span>
  <meta itemprop="author" itemscope="" itemtype="http://schema.org/Person" itemref="author" />
</div>

Has anybody another idea?

Less
  • 33
  • 3

2 Answers2

4

You have three options.

itemid

As described by @Dharmang. You give the Person a URI (with the itemid attribute) and reference this URI in each Book with the author property.

<div itemscope itemtype="http://schema.org/Person" itemid="#person-1">
</div>

<div itemscope itemtype="http://schema.org/Book">
  <link itemprop="author" href="#person-1" />
</div>

<div itemscope itemtype="http://schema.org/Book">
  <link itemprop="author" href="#person-1" />
</div>

(This URI can then used by others that also want to say something about this person, or that want to identify that person. So [your-domain]/[your-path]#person-1 is then a URI that represents the actual person, not just a page about that person. If there is already such a URI for that person, you might want to reuse it instead of creating your own.)

Problem: Consumer support might not be the best (but Google’s testing tool seems to recognize it).

itemref

You have to add itemprop="author" to the Person item, and reference its id from each Book with the itemref attribute. You don’t have to add a meta element for this, you simply do it on the element with the itemscope.

<div itemprop="author" itemscope itemtype="http://schema.org/Person" id="author">
</div>

<div itemscope itemtype="http://schema.org/Book" itemref="author">
</div>

<div itemscope itemtype="http://schema.org/Book" itemref="author">
</div>

Problem: The Person item can’t have a parent with itemscope (because its author property would be added to it). So this means, for example, that you can’t use the mainEntity property to denote that the Person is the primary topic of the WebPage.

itemprop-reverse

If you can nest the Book items in the Person item, you could use the itemprop-reverse attribute, which allows you to use properties in the other direction:

<div itemscope itemtype="http://schema.org/Person">

  <div itemprop-reverse="author" itemscope itemtype="http://schema.org/Book">
  </div>

  <div itemprop-reverse="author" itemscope itemtype="http://schema.org/Book">
  </div>

</div>

(If you can’t nest, you could still use it with a URI value, but using itemid in that case is probably the better choice.)

Problem: This attribute is not part of the Microdata specification. It’s defined in W3C’s Microdata to RDF Note. So consumer support might be not so good. Google’s testing tool doesn’t seem to recognize it.

Community
  • 1
  • 1
unor
  • 92,415
  • 26
  • 211
  • 360
  • Thank you, but as you mentioned the first two solutions will 'cut out' the person-element. When the third solution can't be read by googles testing tool, its crawler will probably do the same. It's tricky. – Less Jul 29 '16 at 16:50
  • @Less: With "cut out", do you mean that Google’s testing tool does not display `Person` in an own section? If yes, that should be no problem: it only lists top-level items that way; all the other items are nested inside such a section (e.g., inside `Book` in your case). It’s just the way Google decided to display the output. – unor Jul 29 '16 at 17:02
  • Yes, that are my thoughts. I don't think it's just a display issue of the testing tool. In my opinion Google will not see the `Person` as the main-entity of the document. – Less Jul 29 '16 at 18:33
  • @Less: I think you have to *tell* consumers what the main entity should be. Having top-level items doesn’t convey that they are more important than nested items. To denote which item is the main entity, you can use the [`mainEntity` property](http://schema.org/mainEntity) (`WebPage` → `mainEntity` → `Person`) (or the inverse [`mainEntityOfPage`](http://schema.org/mainEntityOfPage) if you don’t want a `WebPage` item). – unor Jul 29 '16 at 18:48
  • 1
    Ok, I found your other help: http://stackoverflow.com/questions/34466028/how-to-implement-mainentityofpage-to-this-specific-site The testing tool still shows the book-elements as the top-level items, but with `mainEntityOfPage` it should be clear, that `Person` is the main topic. Thanks! – Less Jul 29 '16 at 20:44
2

You can use link tag to achieve this, check below snippet:

<div itemid="#author-marvin" itemscope="" itemtype="http://schema.org/Person">
  <span itemprop="name">Marvin</span>
</div>
<div itemscope="" itemtype="http://schema.org/Book">
  <span itemprop="name">Nice Book</span>
  <link itemprop="author" href="#author-marvin">
</div>
<div itemscope="" itemtype="http://schema.org/Book">
  <span itemprop="name">Best Book</span>
  <link itemprop="author" href="#author-marvin">
</div>

itemid of author snippet should match the href of link in book snippet throughout the page markup.

More examples here

Dharmang
  • 3,018
  • 35
  • 38
  • Thank you, but in this solution only the book-schemas will be left over, and no instance of the person. – Less Jul 29 '16 at 16:44