schema.org - 用于不同 Schema.org 类型的多个 JSON-LD 脚本:为什么在使用 Google SDTT 进行测试时将它们组合为一种类型?
问题描述
我有一篇包含汽车评论和视频的文章,我想使用 JSON-LD 实现以下 Schema.org 类型Article
:VideoObject
和Review
.
我为每种 Schema.org 类型创建了以下单独的片段:
(一)条:
<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) 视频对象
<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 结构化数据测试工具分别测试每个脚本时,一切都很好,没有错误。
如果我在同一页面中测试所有脚本,我仍然没有收到错误,但所有类型都“组合”为一种 type , Article
,如下图所示。
那是对的吗?
我似乎记得在过去使用 Microdata 而不是 JSON-LD 时有单独的类型Article
,VideoObject
和。Review
解决方案
@id
唯一标识一个事物,因此如果两个事物具有相同的@id
值,则它们是相同的。
您的WebPage
,VideoObject
和Review
具有相同的@id
值:
"@id": "https://www.example.com/articleurl"
如果你想提供@id
s (这是一个很好的做法),它们应该都有不同的值,除非它们真的是相同的。
推荐阅读
- javascript - 在不同的浏览器平台上使用 $.get 为 innerHTML 数据获取一致响应的适当方法是什么?
- php - 达到第 50 条记录时删除所有记录 - sql/php
- .net - 如何在 Angular 客户端中使用 WCF 肥皂 Web 服务
- php - 当变量为空时,是否有一个循环将排除变量,同时回显到php中的网页?
- c - 为什么我在调用 malloc() 为链表创建节点时会出现内存泄漏?
- docker - docker-compose.override.yml 不会覆盖值
- python - 如果元素不是无,如何替换列表中的元素值?
- c++ - 作用域与编译器优化的相关性
- r - 使用 R 中的汇总,按查找汇总度量、非 NA 值和特定值进行分组
- reactjs - 减速器中的 Action.balances 有效负载不更新物理余额