简体   繁体   English

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

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

I am trying to create a product snippet in JSON-LD with multiple reviews. 我试图在JSON-LD中创建具有多个评论的产品代码段。 The code below works when I include only one review. 当我仅包含一个评论时,以下代码有效。 (please copy paste the code fragment in the console on the following url to test it: https://search.google.com/structured-data/testing-tool ). (请将代码片段复制粘贴到控制台中的以下URL上以对其进行测试: https : //search.google.com/structured-data/testing-tool )。 However it is unclear for me how I can add multiple reviews. 但是,对于我来说,尚不清楚如何添加多个评论。 After struggling for some time I can't get it to work myself and I am having a hard time to find an example. 经过一段时间的努力,我自己无法工作,我很难找到一个例子。

Let's say I have a review from "John" who gives the product rating of a "3.0" and another review of "Sarah" who gives the product a rating of "5.0". 假设我有“约翰”的评论,他给产品评分为“ 3.0”,还有另一条“莎拉”评论,给产品评分为“ 5.0”。 How can I include the review of Sarah in the code below? 我如何在下面的代码中包含对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"
     }

}


}

You can attach multiple JSON-LD snippets to a single page, so there's no reason why you couldn't remove the review data from you sample, and move it to a standalone snippet. 您可以将多个JSON-LD代码段附加到单个页面上,因此没有理由无法从示例中删除评论数据,并将其移动到独立代码段中。 Then create another snippet for "Sarah" 然后为“ Sarah”创建另一个代码段

Here's a some boilerplate JSON-LD for a review 这是一些样板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>

If you test this approach with multiple snippets on https://search.google.com/structured-data/testing-tool you'll see that it will validate. 如果您在https://search.google.com/structured-data/testing-tool上使用多个代码片段测试了此方法,则会看到它将会验证。

As an alternative, I have the equivalent of this working on a site. 另外,我也可以在网站上进行等效的操作。 I've removed the individual review and modified your aggregateRating block 我已经删除了单个评论并修改了您的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>

Good luck! 祝好运!

You can specify review as an array, 您可以将评论指定为数组,

<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.

相关问题 如何与 Shopify Storefront 通信并将 JS 片段添加到产品页面 - How to communicate with Shopify Storefront and add JS snippet to Product Page 如何使用 JSON-LD 和变量将 Google Tag Manager 与多架构产品评论结合使用 - How to use Google Tag Manager with Multiple Schema Product reviews using JSON-LD and Variables 如何使用照片添加谷歌评论? - How to add google reviews with photos? 如何将 TypeScript 类型添加到 jQuery 代码片段以用于 Bootstrap 多级下拉菜单? - How can I add TypeScript typings to a snippet of jQuery code for a Bootstrap multilevel dropdown? 如何对该代码段进行单元测试? - How can I unit test this code snippet? 如何使用 angular 和 springboot 添加新产品? - How can I add new product using angular and springboot? 如何为网站产品添加fb like按钮? - how can i add fb like button for my website product? 如何将订单估算器添加到 Shopify 产品详细信息页面 - How can i add Order Estimator to Shopify product details page 如何在“&amp;”字符后添加换行符,而不是代码片段中显示的问题(添加额外的空格,而不是换行符)? - How can I add a newline after my “&” characters, instead of the issue shown in my code snippet (adding extra space, not line breaks)? 如何为正则表达式添加多个条件? - How can I add multiple conditions to regex?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM