组织提供产品的微数据 [英] Microdata for Product with Offer with Organization

查看:95
本文介绍了组织提供产品的微数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试为我的产品页面创建Google Rich Snippets。



我使用
$ b $创建了一个产品b

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

在这款产品中,我有一个优惠,由

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

我想将卖家属性(组织)添加到Offer中,但是,我的HTML结构卖家根据产品而不是根据要约。

 < div itemscope =itemtype =http://模式.ORG /产品> 
< div itemprop =offersitemscope =itemtype =http://schema.org/Offer>
...
< / div>
< div itemprop =selleritemscope =itemtype =http://schema.org/Organization>
...
< / div>
< / div>

然而,这似乎并没有取悦Google结构化数据测试工具。



然后,我尝试在组织上使用 itemref 并使用 meta 要约中的标签

 < div itemscope =itemtype =http://schema.org/Product> ; 
< div itemprop =offersitemscope =itemtype =http://schema.org/Offer>
< meta itemprop =selleritemref =provider>
...
< / div>
< div id =provideritemscope =itemtype =http://schema.org/Organization>
...
< / div>
< / div>

但它似乎仍不认可卖家为组织。



我做错了什么?

解决方案

您没有使用 itemref 正确:




  • itemref 属性必须在具有 itemscope 的元素上指定。

  • 必须使用 itemprop

    所以你的例子应该看起来像:

     < div itemscope itemtype =http://schema.org/Product> 
    < div itemprop =offersitemscope itemtype =http://schema.org/Offeritemref =provider>
    < / div>
    < div id =provideritemprop =selleritemscope itemtype =http://schema.org/Organization>
    < / div>
    < / div>

    但是,不起作用,因为这样, seller 属性将被添加到这两个项目中, Product Offer 。这是无效的,因为 Product 不能有卖家属性。



    因此,您必须更改嵌套,或者不要在容器 div Product >。然而,也有一个丑陋的解决方法:添加一个带有 itemscope 的虚拟元素:

    $ b $


    b

     < div itemscope itemtype =http://schema.org/Product> 
    < div itemprop =offersitemscope itemtype =http://schema.org/Offeritemref =provider>
    < / div>
    < div itemscope>
    < div id =provideritemprop =selleritemscope itemtype =http://schema.org/Organization>
    < / div>
    < / div>
    < / div>


    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?

    解决方案

    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>
    

    这篇关于组织提供产品的微数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆