首页 > 解决方案 > 用于不同 Schema.org 类型的多个 JSON-LD 脚本:为什么在使用 Google SDTT 进行测试时将它们组合为一种类型?

问题描述

我有一篇包含汽车评论和视频的文章,我想使用 JSON-LD 实现以下 Schema.org 类型ArticleVideoObjectReview.

我为每种 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

标签: schema.orgjson-ld

解决方案


@id唯一标识一个事物,因此如果两个事物具有相同的@id值,则它们相同的。

您的WebPage,VideoObjectReview具有相同的@id值:

"@id": "https://www.example.com/articleurl"

如果你想提供@ids (这是一个很好的做法),它们应该都有不同的值,除非它们真的是相同的。


推荐阅读