【问题标题】:Microdata for Product with Offer with Organization带有组织的产品的微数据
【发布时间】:2014-12-12 09:08:58
【问题描述】:

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

我使用

创建了一个产品
<div itemscope="" itemtype="http://schema.org/Product">
  ...
</div>

在这个产品中,我有一个优惠,创建于

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

我想将卖方属性(一个组织)添加到报价中,但是,我的 HTML 结构在产品下而不是报价下有卖方。

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

但是,这似乎并不能让 Google 结构化数据测试工具满意。

然后我尝试在组织上使用itemref 并在报价中使用meta-tag

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

但它似乎仍然不承认卖方是组织。

我做错了什么?

【问题讨论】:

    标签: html microdata rich-snippets google-rich-snippets


    【解决方案1】:

    你没有正确使用itemref

    • 必须在带有itemscope 的元素上指定itemref 属性。
    • 它必须用itemprop 引用一个元素。

    所以你的例子应该是这样的:

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

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

    因此,您要么必须更改嵌套,要么不要在容器 div 上使用 Product

    但是,还有一个丑陋的解决方法:添加一个带有 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>
    

    【讨论】:

    • 谢谢。所以没有办法保留旧的内容布局并拥有正确的架构标记?
    • @MadsOhmLarsen:如果你不能添加一个div 元素(所以Product 不是所有东西的容器),我想不出解决方案。
    猜你喜欢
    • 2021-07-29
    • 1970-01-01
    • 1970-01-01
    • 2020-11-28
    • 2020-03-16
    • 2014-02-16
    • 2016-04-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多