【问题标题】:How to code markup for Product in ItemList?如何在 ItemList 中为产品编码标记?
【发布时间】:2018-06-10 10:18:12
【问题描述】:

我已经改编了来自http://schema.org/ItemList 上的示例 2 的代码

如何与Product 一起使用?在首页和其他一些页面上,我有一个产品列表,我希望对其进行更好的标记。

以下代码给出了错误

位置字段的值是必需的。

但是Product 没有位置,所以如果position 有一个值,它会给出不同的错误。

<ul itemscope itemtype="http://schema.org/ItemList">
    <meta itemprop="numberOfItems" content="10" />

        <li itemprop="itemListElement" itemscope itemtype="http://schema.org/Product">

            <!-- <meta itemprop="position" content="1" /> -->

            <a href="#" itemprop="url">
                <img src="asdf.jpg" itemprop="image">
                <div class="product-list__title" itemprop="name">
                    Product name
                </div>
                <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">
                    <div itemprop="price">
                        $12
                    </div>
                    <link itemprop="availability" href="http://schema.org/InStock" />
                </div>
            </a>

        </li>

</ul>

【问题讨论】:

    标签: schema.org microdata


    【解决方案1】:

    itemListElement 属性具有三个预期值:

    • ListItem
    • Text
    • Thing

    ListItem 也是一个Thing,但它被明确列出是因为它在这里有一个特殊的作用:ListItem 提供了position 属性。如果您需要传达列表项的位置,则必须提供ListItem 值。

    请注意,并非每个ItemList 都需要这个。您使用Product 值的示例很好(除了不能是ul 的子元素的meta 元素),除非您尝试获得Google 丰富结果的资格(这就是错误消息的内容),你可以保持这样。

    如果您确实想提供职位,itemListElement 可能如下所示:

    <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
      <meta itemprop="position" content="1" />
      <div itemprop="item" itemscope itemtype="http://schema.org/Product">
        <!-- your Product -->
      </div>
    </li>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-05-17
      • 2016-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-21
      • 2021-05-05
      相关资源
      最近更新 更多