我正在尝试使用Microdata通过Schema.org定义来定义我的网站。
下面是我当前的HTML标记:
<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>
当我使用Structured Data Testing Tool验证代码时,相似产品部分显示为单独的节点,而不是ItemPage
的一部分。
ItemPage
如何在正在定义的当前产品下正确列出相关的相似产品?
isSimilarTo
<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>
如果无法将类似产品嵌套在主要产品的HTML元素下,则可以使用Microdata的itemref
(itemref
)。
((仅当不可能使用解决方案1或2时,才应采用这种方式,因为并非所有消费者都将支持此解决方案3。]
类似于您当前正在使用的产品,您可以给主产品一个URI作为标识符(具有Microdata的example属性,并引用该URI作为类似产品中itemid
的值。
isSimilarTo