重复的模式/结构化数据标记? [英] Duplicate schema/structured data markup?
问题描述
这种结构会有问题吗?
<script type="application/ld+json">
{
"@context":"http://schema.org",
"@type":"WebPage",
"name":"Postcards",
"url":"https://local.mysite.com/postcards.html",
"breadcrumb":{
"@type":"BreadcrumbList",
"itemListElement":[
{
"@type":"ListItem",
"position":1,
"item":{
"@id":"https://local.mysite.com",
"name":"My Site"
}
},
{
"@type":"ListItem",
"position":2,
"item":{
"@id":"https://local.mysite.com/postcards.html",
"name":"Postcards"
}
}
]
},
"mainEntity":{
"@type":"WebPageElement",
"offers":{
"@type":"Offer",
"itemOffered":[
{
"@type":"Product",
"name":"Christmas Postcards",
"url":"https://local.mysite.com/christmas-postcards.html"
},
{
"@type":"Product",
"name":"Getaway Postcards",
"url":"https://local.mysite.com/getaway-postcards.html"
}
]
}
}
}</script>
<script type="application/ld+json">
{
"@context":"http://schema.org",
"@type":"WebPage",
"name":"Postcards",
"url":"https://local.mysite.com/postcards.html",
"breadcrumb":{
"@type":"BreadcrumbList",
"itemListElement":[
{
"@type":"ListItem",
"position":1,
"item":{
"@id":"https://local.mysite.com",
"name":"My Site"
}
},
{
"@type":"ListItem",
"position":2,
"item":{
"@id":"https://local.mysite.com/postcards.html",
"name":"Postcards"
}
}
]
},
"mainEntity":{
"@type":"WebPageElement",
"offers":{
"@type":"Offer",
"itemOffered":[
{
"@type":"Product",
"name":"Mini Postcards",
"url":"https://local.mysite.com/mini-postcards.html"
},
{
"@type":"Product",
"name":"Summer Postcards",
"url":"https://local.mysite.com/summer-postcards.html"
}
]
}
}
}</script>
对于单个类别页面可能存在这样的重复"标记的原因是该页面可能使用多个产品模板.
The reason there could be "duplicate" markup like this for a single category page is that the page may use multiple product templates.
在当前实现中,标记是在产品模板中动态构建的.例如,如果单个类别页面有两个产品模板,则标记将重建两次,但包含不同的 WebPageElement
.
In the current implementation, the markup is dynamically constructed in the product template. For example, if there are two product templates for a single Category Page, the markup will be reconstructed twice, but containing different WebPageElement
.
这会产生不好的结果吗?我检查了 Google 的测试工具,它没有给我任何错误或警告.
Will this yield bad results? I checked in Google's testing tool and it didn't give me any errors or warnings.
推荐答案
多个节点,同一个实体
如果您有多个节点代表页面上的同一实体,最佳做法是为这些节点提供相同的 URI 作为标识符.
使用 JSON-LD,您可以提供带有 @id
的标识符.
With JSON-LD, you can provide identifiers with @id
.
所以
- 您的两个
WebPage
项目都可以获取"@id": ""
(对于当前 URL;最好在此处指定您的规范 URL), - 您的两个
BreadcrumbList
项目都可以得到"@id": "#breadcrumbs"
, - 您的
ListItem
-1 项都可以得到"@id": "#breadcrumbs-1"
和 - 您的
ListItem
-2 项都可以得到"@id": "#breadcrumbs-2"
.
- both of your
WebPage
items could get"@id": ""
(for the current URL; preferably specify your canonical URL here), - both of your
BreadcrumbList
items could get"@id": "#breadcrumbs"
, - both of your
ListItem
-1 items could get"@id": "#breadcrumbs-1"
, and - both of your
ListItem
-2 items could get"@id": "#breadcrumbs-2"
.
这样,Google 的 SDTT 将只显示这些项目中的每一个,因为它现在知道它们是关于同一个实体的.
That way, Google’s SDTT will display each of these items only once, because it now knows that they are about the same entity.
@id
还允许您引用节点而不是嵌入它们(从而复制它们的数据).查看示例.
@id
also allows you to reference nodes instead of embedding them (and thereby duplicating their data). See an example.
在您的情况下,这样做的好处是您不必复制 WebPage
/BreadcrumbList
/ListItem
节点开始.您只需指定这些节点一次,然后每个产品模板将仅输出 Offer
/Product
节点.这些节点可以包括对 WebPage
/etc 的(反向)引用.(可能更容易实现),或 WebPage
/etc.可以引用这些节点.
In your case this would have the advantage that you don’t have to duplicate the WebPage
/BreadcrumbList
/ListItem
nodes to begin with. You would specify these nodes once, and each product template would then outpout only the Offer
/Product
nodes. These nodes could include (reverse) references to the WebPage
/etc. (might be easier for you to implement), or the WebPage
/etc. could reference these nodes.
这篇关于重复的模式/结构化数据标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!