我正在尝试使用Schema.org定义使用Microdata定义我的网站。在ItemPage
上,我正在显示有关产品的信息。此外,我想在相关产品显示在当前产品范围之外时单击ItemPage
。
我试图使用link similar products to the current product属性来实现这一目标。但是,当我查看itemref
上的页面时,它没有显示相关产品属于itemref
节点的一部分。
Structured Data Testing Tool
必须以其他方式使用:
ItemPage
属性必须位于表示要向其添加属性的项目的元素上。这将是您的主要产品。
您要添加的元素需要<body itemscope itemtype="http://schema.org/ItemPage">
<header itemprop="hasPart" itemscope itemtype="http://schema.org/WPHeader">
</header>
<article itemprop="mainEntity" itemscope itemtype="http://schema.org/Product" id="details_10">
<h2 itemprop="name">Product 10</h2>
</article>
<aside>
<article itemref="details_10" itemscope itemtype="http://schema.org/Product">
<h3 itemprop="name">Product 20</h3>
</article>
<article itemref="details_10" itemscope itemtype="http://schema.org/Product">
<h3 itemprop="name">Product 30</h3>
</article>
</aside>
<footer itemprop="hasPart" itemscope itemtype="http://schema.org/WPFooter">
</footer>
</body>
属性(缺少itemref
属性),以及需要itemprop
属性引用的isSimilarTo
。在您的情况下,这些将是类似的产品。
所以,这将给:
id
此标记的问题是,两个itemref
属性也被添加到<body itemscope itemtype="http://schema.org/ItemPage">
<article itemprop="mainEntity" itemscope itemtype="http://schema.org/Product" itemref="details_20 details_30"></article>
<aside>
<article id="details_20" itemprop="isSimilarTo" itemscope itemtype="http://schema.org/Product"></article>
<article id="details_30" itemprop="isSimilarTo" itemscope itemtype="http://schema.org/Product"></article>
</aside>
</body>
(因为它们嵌套在它的下面),这是不正确的。为了避免这种情况,最好的解决方案是不在isSimilarTo
元素上指定ItemPage
,而在ItemPage
或类似元素上指定。
body
((您也可以使用div
来避免将主<body>
<div itemscope itemtype="http://schema.org/ItemPage">
<article itemprop="mainEntity" itemscope itemtype="http://schema.org/Product" itemref="details_20 details_30"></article>
</div>
<aside>
<article id="details_20" itemprop="isSimilarTo" itemscope itemtype="http://schema.org/Product"></article>
<article id="details_30" itemprop="isSimilarTo" itemscope itemtype="http://schema.org/Product"></article>
</aside>
</body>
嵌套在itemref
下。例如,这也可以在Product
元素上指定ItemPage
。)