多个 JSON-LD 脚本用于不同的 Schema.org 类型:为什么在使用 Google SDTT 测试时将它们合并为一种类型?
Several JSON-LD scripts for different Schema.org types: why they're combined into one type when testing with Google SDTT?
我有一篇包含汽车评论和视频的文章,我想实现以下 Schema.org 类型,JSON-LD:Article
、VideoObject
和 Review
.
我为每个 Schema.org 类型创建了以下单独的片段:
(1) 文章:
<script type="application/ld+json">
{ "@context": "https://schema.org",
"@type": "Article",
"name": "TitleOfArticle",
"headline": "TitleOfArticle",
"description": "DescriptionOfArticle",
"image": {
"@type": "ImageObject",
"url": "https://www.example.com/imageofcarinarticle.png",
"width": 1200,
"height": 800
},
"author": {
"@type": "Person",
"name": "John Smith"
},
"wordcount": "628",
"publisher": {
"@type": "Organization",
"name": "MyCompany",
"logo": {
"@type": "ImageObject",
"url": "https://www.example.com/companylogo.png"
}
},
"url": "https://www.example.com/articleurl",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://www.example.com/articleurl"
},
"datePublished": "2019-09-16T11:30:19",
"dateCreated": "2019-09-16T11:30:19",
"dateModified": "2019-09-16T11:30:19",
"thumbnailUrl": "https://www.example.com/imageofcar.png"
}
</script>
2) VideoObject
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "VideoObject",
"name": "TitleOfArticle",
"@id": "https://www.example.com/articleurl",
"datePublished": "2019-09-16T11:30:19",
"uploadDate": "2019-09-16T11:30:19",
"duration": "PT5M33S",
"description" : "DescriptionOfArticle",
"thumbnailURL" : "https://www.example.com/thumbnailurl.png",
"thumbnail" : "https://www.example.com/thumbnailurl.png",
"contentUrl": "https://www.example.com/videourl.mp4",
"author": {
"@type": "Person",
"name": "John Smith"
}
}
</script>
3) 回顾
<script type='application/ld+json'>
{
"@context": "https://schema.org/",
"@type": "Review",
"itemReviewed": {
"@type": "Car",
"name": "Mini Countryman",
"model": "Countryman",
"manufacturer": "Mini",
"bodyType": "hatchback",
"vehicleModelDate": "2019"
},
"author": {
"@type": "Person",
"name": "John Smith"
},
"image": {
"@type": "ImageObject",
"url": "https://www.example.com/imageofcarinarticle.png",
"width": 1200,
"height": 800
},
"publisher": {
"@type": "Organization",
"name": "MyCompany",
"logo": {
"@type": "ImageObject",
"url": "https://www.example.com/companylogo.png"
}
},
"@id": "https://www.example.com/articleurl",
"headline": "TitleOfArticle",
"description": "DescriptionOfArticle",
"datePublished": "2019-09-16T11:30:19",
"dateModified": "2019-09-16T11:30:19",
"reviewBody": "ReviewOfCar",
"reviewRating": {
"@type": "Rating",
"ratingValue": "6.0",
"bestRating": "10"
}
}
</script>
当我使用 Google 结构化数据测试工具分别测试每个脚本时,一切都很好,没有错误。
如果我在同一个页面测试所有的脚本,我仍然没有报错,但是所有的类型都'组合'成一个类型,Article
,as在下图中。
对吗?
我似乎记得在过去使用 Microdata 而不是 JSON-LD 时有不同的类型,Article
、VideoObject
和 Review
。
@id
唯一标识一个事物,因此如果两个事物具有相同的 @id
值,则它们 相同。
您的 WebPage
、VideoObject
和 Review
具有相同的 @id
值:
"@id": "https://www.example.com/articleurl"
如果你想提供 @id
s(这是一个很好的做法),它们都应该有不同的值,除非它们真的是一样的。
我有一篇包含汽车评论和视频的文章,我想实现以下 Schema.org 类型,JSON-LD:Article
、VideoObject
和 Review
.
我为每个 Schema.org 类型创建了以下单独的片段:
(1) 文章:
<script type="application/ld+json">
{ "@context": "https://schema.org",
"@type": "Article",
"name": "TitleOfArticle",
"headline": "TitleOfArticle",
"description": "DescriptionOfArticle",
"image": {
"@type": "ImageObject",
"url": "https://www.example.com/imageofcarinarticle.png",
"width": 1200,
"height": 800
},
"author": {
"@type": "Person",
"name": "John Smith"
},
"wordcount": "628",
"publisher": {
"@type": "Organization",
"name": "MyCompany",
"logo": {
"@type": "ImageObject",
"url": "https://www.example.com/companylogo.png"
}
},
"url": "https://www.example.com/articleurl",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://www.example.com/articleurl"
},
"datePublished": "2019-09-16T11:30:19",
"dateCreated": "2019-09-16T11:30:19",
"dateModified": "2019-09-16T11:30:19",
"thumbnailUrl": "https://www.example.com/imageofcar.png"
}
</script>
2) VideoObject
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "VideoObject",
"name": "TitleOfArticle",
"@id": "https://www.example.com/articleurl",
"datePublished": "2019-09-16T11:30:19",
"uploadDate": "2019-09-16T11:30:19",
"duration": "PT5M33S",
"description" : "DescriptionOfArticle",
"thumbnailURL" : "https://www.example.com/thumbnailurl.png",
"thumbnail" : "https://www.example.com/thumbnailurl.png",
"contentUrl": "https://www.example.com/videourl.mp4",
"author": {
"@type": "Person",
"name": "John Smith"
}
}
</script>
3) 回顾
<script type='application/ld+json'>
{
"@context": "https://schema.org/",
"@type": "Review",
"itemReviewed": {
"@type": "Car",
"name": "Mini Countryman",
"model": "Countryman",
"manufacturer": "Mini",
"bodyType": "hatchback",
"vehicleModelDate": "2019"
},
"author": {
"@type": "Person",
"name": "John Smith"
},
"image": {
"@type": "ImageObject",
"url": "https://www.example.com/imageofcarinarticle.png",
"width": 1200,
"height": 800
},
"publisher": {
"@type": "Organization",
"name": "MyCompany",
"logo": {
"@type": "ImageObject",
"url": "https://www.example.com/companylogo.png"
}
},
"@id": "https://www.example.com/articleurl",
"headline": "TitleOfArticle",
"description": "DescriptionOfArticle",
"datePublished": "2019-09-16T11:30:19",
"dateModified": "2019-09-16T11:30:19",
"reviewBody": "ReviewOfCar",
"reviewRating": {
"@type": "Rating",
"ratingValue": "6.0",
"bestRating": "10"
}
}
</script>
当我使用 Google 结构化数据测试工具分别测试每个脚本时,一切都很好,没有错误。
如果我在同一个页面测试所有的脚本,我仍然没有报错,但是所有的类型都'组合'成一个类型,Article
,as在下图中。
对吗?
我似乎记得在过去使用 Microdata 而不是 JSON-LD 时有不同的类型,Article
、VideoObject
和 Review
。
@id
唯一标识一个事物,因此如果两个事物具有相同的 @id
值,则它们 相同。
您的 WebPage
、VideoObject
和 Review
具有相同的 @id
值:
"@id": "https://www.example.com/articleurl"
如果你想提供 @id
s(这是一个很好的做法),它们都应该有不同的值,除非它们真的是一样的。