Microdata for Product with Offer with Organization

会有一股神秘感。 提交于 2019-12-25 01:44:10

问题


I'm trying to create Google Rich Snippets for my Product page.

I've created a Product using

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

Inside this product, I have an Offer, created with

<div itemscope="" itemtype="http://schema.org/Product">
  <div itemprop="offers" itemscope="" itemtype="http://schema.org/Offer">
    ...
  </div>
</div>

I want to add the seller property (an Organization) to the Offer, however, my HTML structure have the seller under the Product and not under the Offer.

<div itemscope="" itemtype="http://schema.org/Product">
  <div itemprop="offers" itemscope="" itemtype="http://schema.org/Offer">
    ...
  </div>
  <div itemprop="seller" itemscope="" itemtype="http://schema.org/Organization">
    ...
  </div>
</div>

However, this doesn't seem to please the Google Structured Data testing tool.

I have then tried with using itemref on the Organization and using a meta-tag in the Offer

<div itemscope="" itemtype="http://schema.org/Product">
  <div itemprop="offers" itemscope="" itemtype="http://schema.org/Offer">
    <meta itemprop="seller" itemref="provider">
    ...
  </div>
  <div id="provider" itemscope="" itemtype="http://schema.org/Organization">
    ...
  </div>
</div>

But it still doesn't seem to recognize the seller as the Organization.

What am I doing wrong?


回答1:


You are not using itemref correctly:

  • The itemref attribute has to be specified on an element with itemscope.
  • It has to reference an element with itemprop.

So your example would have to look like:

<div itemscope itemtype="http://schema.org/Product">
  <div itemprop="offers" itemscope itemtype="http://schema.org/Offer" itemref="provider">
  </div>
  <div id="provider" itemprop="seller" itemscope itemtype="http://schema.org/Organization">
  </div>
</div>

But this does not work, because this way, the seller property will be added to both items, Product and Offer. This is not valid because Product can’t have the seller property.

So you would either have to change the nesting, or don’t use Product on the container div.

However, there’s also an ugly fix: add a dummy element with itemscope:

<div itemscope itemtype="http://schema.org/Product">
  <div itemprop="offers" itemscope itemtype="http://schema.org/Offer" itemref="provider">
  </div>
  <div itemscope>
    <div id="provider" itemprop="seller" itemscope itemtype="http://schema.org/Organization">
    </div>
  </div>
</div>


来源:https://stackoverflow.com/questions/27440195/microdata-for-product-with-offer-with-organization

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