Microdata itemref - multiple references to the same item

自古美人都是妖i 提交于 2019-12-11 21:08:58

问题


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"?


回答1:


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>


来源:https://stackoverflow.com/questions/24080142/microdata-itemref-multiple-references-to-the-same-item

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!