Lieuwe
Lieuwe

Reputation: 1842

Microdata itemref - multiple references to the same item

I have an item that I am trying to reference from several other items on my page and I am struggling to get this right, hopefully someone can enlighten me. One of several attempts is this:

<div id="daughter">
    <span itemprop="name">Mary</span>
</div>

<div itemscope itemtype="http://schema.org/Person">
    <span itemprop="name">John</span>
    <meta itemprop="children" itemscope itemtype="http://schema.org/Person" itemref="daughter"/>
</div>

<div itemscope itemtype="http://schema.org/Person">
    <span itemprop="name">Julie</span>
    <meta itemprop="children" itemscope itemtype="http://schema.org/Person" itemref="daughter"/>
</div>

However if I test this with the Google structured data tool, it produces 2 instances (items) of Mary. I guess this is correct as I am adding an itemscope attribute to the meta tag, but it isn't the result I want.

What is the correct way (if any) of creating 1 item of type "Person" (the child) which is referred to by several other items of type "Person" (the parents) using its property "children"?

Upvotes: 1

Views: 329

Answers (1)

Lieuwe
Lieuwe

Reputation: 1842

Finally stumbled upon the answer .. the following code does what I was looking for - incase it helps anyone else.

<div id="daughter" itemprop="children" itemscope itemtype="http://schema.org/Person">
    <span itemprop="name">Mary</span>
</div>

<div itemscope itemtype="http://schema.org/Person" itemref="daughter">
    <span itemprop="name">John</span>
</div>

<div itemscope itemtype="http://schema.org/Person" itemref="daughter">
    <span itemprop="name">Julie</span>
</div>

Upvotes: 3

Related Questions