如何在ItemPage上使用Microdata来表示同类产品? [英] How to use Microdata to represent similar products on the ItemPage?

查看:51
本文介绍了如何在ItemPage上使用Microdata来表示同类产品?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Microdata 使用 Schema.org 定义来定义我的网站.

以下是我当前的 HTML 标记:

<link itemprop="url" href="https://example.com/i/10"/><主要角色=主要"><!-- 显示页面的主要产品--><div itemprop="mainEntity" itemtype="http://schema.org/Product" itemscope><meta itemprop="name" content="My Main Product 10 Name"/><!-- ... 描述当前产品的更多属性-->

<!-- 当前正在查看的产品的 10 个类似产品列表 --><div class="list-related-products"><div itemtype="http://schema.org/Product" itemscope><meta itemprop="name" content="Related Product 20 Name"/><meta itemprop="url" content="https://example.com/i/20"/><div itemprop="isSimilarTo" itemscope itemtype="http://schema.org/Product"><link itemprop="url" href="https://example.com/i/10"/>

<!-- ...更多属性-->

<!-- ... 更多产品-->

</main>

当我使用

如何在当前定义的产品下正确列出相关的同类产品?

解决方案

解决方案 1:嵌套

您可以在主要产品中添加isSimilarTo:

<h2 itemprop="name">产品 10</h2><旁边><article itemprop="isSimilarTo" itemscope itemtype="http://schema.org/Product"><h3 itemprop="name">产品 20</h3></文章><article itemprop="isSimilarTo" itemscope itemtype="http://schema.org/Product"><h3 itemprop="name">产品 30</h3></文章></一边></文章>

方案二:itemref

如果您不能在主要产品的 HTML 元素下嵌套类似产品,您可以使用 Microdata 的 itemref (示例).

解决方案 3:ID

(只有在解决方案 1 或 2 不可行时才应该这样做,因为并非所有消费者都会支持此解决方案 3.)

与您当前使用的类似,您可以为主要产品提供一个 URI 作为标识符(使用 Microdata 的 itemid 属性)并将此 URI 作为 isSimilarTo 的值引用> 在同类产品中.

I am trying to use Microdata to define my website using the Schema.org definitions.

Below is my current HTML markup:

<body itemscope itemtype="http://schema.org/ItemPage">
<link itemprop="url" href="https://example.com/i/10" />

<main role="main">

    <!-- Show the main product of the page -->           
    <div itemprop="mainEntity" itemtype="http://schema.org/Product" itemscope>
        <meta itemprop="name" content="My Main Product 10 Name" />
        <!-- ... more properties that describes current product -->   
    </div>


    <!-- List of 10 similar product the current product being viewed -->
    <div class="list-related-products">

        <div itemtype="http://schema.org/Product" itemscope>
            <meta itemprop="name" content="Related Product 20 Name" />
            <meta itemprop="url" content="https://example.com/i/20" />
            <div itemprop="isSimilarTo" itemscope itemtype="http://schema.org/Product">
                <link itemprop="url" href="https://example.com/i/10" />
            </div>
            <!-- ... more properties -->   
        </div>

        <!-- ... more products -->   
    </div>
</main>

</body>

When I validate the code using Structured Data Testing Tool, the similar products section shows up as a separate nodes and not part of the ItemPage.

How can I list the related similar products correctly under the current product being defined?

解决方案

Solution 1: nesting

You can add isSimilarTo inside the primary product:

<article itemprop="mainEntity" itemscope itemtype="http://schema.org/Product">
  <h2 itemprop="name">Product 10</h2>

  <aside>
    <article itemprop="isSimilarTo" itemscope itemtype="http://schema.org/Product">
      <h3 itemprop="name">Product 20</h3>
    </article>

    <article itemprop="isSimilarTo" itemscope itemtype="http://schema.org/Product">
      <h3 itemprop="name">Product 30</h3>
    </article>
  </aside>

</article>

Solution 2: itemref

If you can’t nest the similar products under the HTML element for the primary product, you could use Microdata’s itemref (example).

Solution 3: ID

(You should only go this way if solutions 1 or 2 aren’t possible, as not all consumers will support this solution 3.)

Similar to what you’re currently using, you can give the primary product an URI as identifier (with Microdata’s itemid attribute) and reference this URI as value for the isSimilarTo inside the similar products.

<article itemprop="mainEntity" itemscope itemtype="http://schema.org/Product" itemid="https://example.com/i/10#this">
  <h2 itemprop="name">Product 10</h2>
</article>

<aside>
  <article itemscope itemtype="http://schema.org/Product">
      <h3 itemprop="name">Product 20</h3>
      <link itemprop="isSimilarTo" href="https://example.com/i/10#this" />
  </article>

  <article itemscope itemtype="http://schema.org/Product">
      <h3 itemprop="name">Product 30</h3>
      <link itemprop="isSimilarTo" href="https://example.com/i/10#this" />
  </article>
</aside>

这篇关于如何在ItemPage上使用Microdata来表示同类产品?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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