繁体   English   中英

如何在产品片段中添加多个评论?

[英]How can I add multiple reviews to a product snippet?

我试图在JSON-LD中创建具有多个评论的产品代码段。 当我仅包含一个评论时,以下代码有效。 (请将代码片段复制粘贴到控制台中的以下URL上以对其进行测试: https : //search.google.com/structured-data/testing-tool )。 但是,对于我来说,尚不清楚如何添加多个评论。 经过一段时间的努力,我自己无法工作,我很难找到一个例子。

假设我有“约翰”的评论,他给产品评分为“ 3.0”,还有另一条“莎拉”评论,给产品评分为“ 5.0”。 我如何在下面的代码中包含对Sarah的评论?

 {
   "@context": "http://schema.org/",
   "@type": "Product",
   "name": "Samsung Galaxy S",  
   "description": "A great product",
   "brand": {
"@type": "Thing",
    "name": "Samsung"
},
"aggregateRating": {
    "@type": "AggregateRating",
    "ratingValue": "4.0",
    "reviewCount": "103"
},
"offers": {
    "@type": "Offer",
     "priceCurrency": "EUR",
     "price": "18",
     "itemCondition": "http://schema.org/NewCondition",
     "availability": "http://schema.org/InStock",
     "seller": {
        "@type": "Organization",
        "name": "Samsung"
    }

}
,"review": {
    "@type": "Review",
     "author": "John",
    "datePublished": " 7 December 2016",
    "description": "I love this product so much",
    "name": "Amazing",
    "reviewRating": {
         "@type": "Rating",
         "bestRating": "5",
         "ratingValue": "3.0",
         "worstRating": "1"
     }

}


}

您可以将多个JSON-LD代码段附加到单个页面上,因此没有理由无法从示例中删除评论数据,并将其移动到独立代码段中。 然后为“ Sarah”创建另一个代码段

这是一些样板JSON-LD进行审查

<script type="application/ld+json">
{
  "@context": "http://schema.org/",
  "@type": "Product",
  "image": "http://www.example.com/iphone-case.jpg",
  "name": "The Catcher in the Rye",
  "review": {
    "@type": "Review",
    "reviewRating": {
      "@type": "Rating",
      "ratingValue": "4"
    },
    "name": "iPhone 6 Case Plus",
    "author": {
      "@type": "Person",
      "name": "Linus Torvalds"
    },
    "datePublished": "2016-04-04",
    "reviewBody": "I loved this case, it is strurdy and lightweight. Only issue is that it smudges.",
    "publisher": {
      "@type": "Organization",
      "name": "iPhone 6 Cases Inc."
    }
  }
}
</script>

如果您在https://search.google.com/structured-data/testing-tool上使用多个代码片段测试了此方法,则会看到它将会验证。

另外,我也可以在网站上进行等效的操作。 我已经删除了单个评论并修改了您的aggregateRating块

<script type="application/ld+json"> {
   "@context": "http://schema.org/",
   "@type": "Product",
   "name": "Samsung Galaxy S",  
   "description": "A great product",
   "brand": {
        "@type": "Thing",
        "name": "Samsung"
    },
    "aggregateRating": {
        "@type": "AggregateRating",
        "ratingValue": "4",
        "reviewCount": "103",
        "worstRating": "1",
        "bestRating": "5"
    },
    "offers": {
        "@type": "Offer",
        "priceCurrency": "EUR",
        "price": "18",
        "itemCondition": "http://schema.org/NewCondition",
        "availability": "http://schema.org/InStock",
        "seller": {
        "@type": "Organization",
        "name": "Samsung"
        }
    }
}</script>

祝好运!

您可以将评论指定为数组,

<script type="application/ld+json">
{
  "@context": "http://schema.org/",
  "@type": "Product",
  "image": "http://www.example.com/iphone-case.jpg",
  "name": "The Catcher in the Rye",
  "review": [
    {
      "@type": "Review",
      "reviewRating": {
        "@type": "Rating",
        "ratingValue": "4"
      },
      "name": "iPhone 6 Case Plus",
      "author": {
        "@type": "Person",
        "name": "Linus Torvalds"
      },
      "datePublished": "2016-04-04",
      "reviewBody": "I loved this case, it is strurdy and lightweight. Only issue is that it smudges.",
      "publisher": {
        "@type": "Organization",
        "name": "iPhone 6 Cases Inc."
      }
    },
    {
      "@type": "Review",
      "reviewRating": {
        "@type": "Rating",
        "ratingValue": "4"
      },
      "name": "iPhone 6 Case Plus+",
      "author": {
        "@type": "Person",
        "name": "Linus Torvalds"
      },
      "datePublished": "2019-04-04",
      "reviewBody": "I loved this case, it is strurdy and lightweight. Only issue is that it smudges.",
      "publisher": {
        "@type": "Organization",
        "name": "iPhone 6 Cases Inc."
      }
    }
  ]
}

</script>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM