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?
You have three options.
itemid
As described by @Dharmang. You give the
Person
a URI (with theitemid
attribute) and reference this URI in eachBook
with theauthor
property.(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 thePerson
item, and reference itsid
from eachBook
with theitemref
attribute. You don’t have to add ameta
element for this, you simply do it on the element with theitemscope
.Problem: The
Person
item can’t have a parent withitemscope
(because itsauthor
property would be added to it). So this means, for example, that you can’t use themainEntity
property to denote that thePerson
is the primary topic of theWebPage
.itemprop-reverse
If you can nest the
Book
items in thePerson
item, you could use theitemprop-reverse
attribute, which allows you to use properties in the other direction:(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.
You can use
link
tag to achieve this, check below snippet:itemid
of author snippet should match thehref
oflink
in book snippet throughout the page markup.More examples here