schema.org - 如何为 ItemList 中的产品编写标记?

标签 schema.org microdata

我改编了 http://schema.org/ItemList 上示例 2 中的代码

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

下面的代码给出了错误

A value for the position field is required.

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

最佳答案

itemListElement属性具有三个期望值:

  • 列表项
  • 文本
  • 事物

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

请注意,并非每个 ItemList 都需要它。使用 Product 值的示例很好(除了 meta 元素不能是 ul 的子元素),除非您尝试为了获得 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>

关于schema.org - 如何为 ItemList 中的产品编写标记?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50782676/

相关文章:

schema.org - 如何使用 Schema.org for Google 标记在线事件?

seo - Schema.org 微格式未包含在搜索结果中

schema.org - 为 http ://schema. org/workLocation 创建三元组

schema.org - 使 'Review' 属于 Microdata 中的 'Product'

schema.org - 我应该使用什么语义网络标识符?

html - 将微数据实现到非 HTML5 页面

breadcrumbs - 带有 Schema.org 的 Breadcrumb 未显示在 Google Rich Snippets 测试工具中

schema.org - 错误 : Page contains property "price" which is not part of the schema

schema.org - Google 会接受组合的 JSON-LD 和 HTML 元/微数据吗?

asp-classic - 微数据标记页面生成随机问号