Link `isRelated` schema.org to parent `Product` when not contained in child element

爱⌒轻易说出口 提交于 2019-12-19 11:46:29

问题


I'm trying to indicate multiple related products on a product page using schema.org microdata. But the child products are orphaned because they are not contained in the parent div. I tried using itemref but I must be using it incorrectly or it must be the wrong solution.

ALSO, I cannot easily create a wrapper div or use the body element to create the parent. My ideal solution would be one that leaves the page structure as-is, and somehow links the "child product" divs to the parent. I thought itemref would do that, but it doesn't appear to be working.

Here is example HTML.

<div id="main-product" itemscope itemtype="http://schema.org/Product">

  <div class="product-name">
      <h1 itemprop="name">Main Product</h1>
  </div>
</div>
<!-- END main-product div -->
<!-- START related-products div -->
<div class="related-products">
<ol class="products-list" id="related-products-list">
  <li class="item">
    <div class="product" itemprop="isRelatedTo" itemscope itemtype="http://schema.org/Product" itemref="main-product">
      <p class="product-name"><a itemprop="url" href="/some_product1.php"><span itemprop="name">Some Product 1</span></a></p>                
    </div>
  </li>
  <li class="item">
    <div class="product" itemprop="isRelatedTo" itemscope itemtype="http://schema.org/Product" itemref="main-product">
      <p class="product-name"><a itemprop="url" href="/some_product2.php"><span itemprop="name">Some Product 2</span></a></p>                
    </div>
   </li>
</ol>
</div>

The above HTML is simplified, but similar in structure to what's on my site and gives similar errors when submitted to validators.

E.g. http://webmaster.yandex.com/microtest.xml

Gives:

microdata
ERROR: unable to determine affiliation of these fields. There are two possible reasons: this fields are incorrectly placed or an orphan itemprop attribute is indicated
itemType = orphans
isrelatedto
product
itemType = http://schema.org/Product
url
href = /some_product1.php
text = Some Product 1
name = Some Product 1
isrelatedto
product
itemType = http://schema.org/Product
url
href = /some_product2.php
text = Some Product 2
name = Some Product 2

product
itemType = http://schema.org/Product
name = Main Product

The Google validator does not seem to show any errors, but the child products are not related to the parent product.


回答1:


You don’t use itemref correctly.

You’d have to specify itemref on the main product instead of the related products:

<div itemref="product-1 product-2" itemscope itemtype="http://schema.org/Product">
  <span itemprop="name">Product</span>
</div>

<div id="product-1" itemprop="isRelatedTo" itemscope itemtype="http://schema.org/Product">
  <span itemprop="name">Product 1</span>
</div>

<div id="product-2" itemprop="isRelatedTo" itemscope itemtype="http://schema.org/Product">
  <span itemprop="name">Product 2</span>
</div>


来源:https://stackoverflow.com/questions/20413068/link-isrelated-schema-org-to-parent-product-when-not-contained-in-child-elem

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