html5 – 一个页面中的多个JSON-LD标签组

前端之家收集整理的这篇文章主要介绍了html5 – 一个页面中的多个JSON-LD标签组前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
可以在同一页面中使用多个 JSON-LD组(使用Schema.org)吗?

如果我不能,怎么把它们结合在一起?我不太熟悉语法.

第1组:

<script type="application/ld+json">
{
  "@context": "http://schema.org","@type": "LocalBusiness","address": {
    "@type": "PostalAddress","streetAddress": "3102 Highway 98","addressRegion": "FL","addressLocality": "Mexico Beach","postalCode": "45252","addressCountry": "US",},"geo": {
    "@type": "GeoCoordinates","latitude": "40.75","longitude": "73.98"
  },"name": "Beachwalk Beachwear & Giftware","telephone": "850-648-4200","email": "admin@example.com","faxNumber": "860-562-4250",}
</script>

第2组:

<script type="application/ld+json">
{
    "@context": "http://schema.org","@type": "Organization","url": "http://example.com","name": "My Domain Title","logo": "http://example.com/wp-content/uploads/2015/08/abc.jpg","contactPoint": [
        {
            "@type": "ContactPoint","telephone": "0192-39192130","contactType": "customer service"
        },{
            "@type": "ContactPoint","telephone": "0182-239120398","contactType": "customer service"
        }
    ],"sameAs": [
        "http://facebook.com/myfbaccount","http://twitter.com/mytwitteraccount"
    ]
}
</script>

解决方法

您可以在页面上拥有多个脚本块,也可以将其组合到单个块中.将它们组合成单个块的最简单方法是使用@graph关键字,如下所示:
<script type="application/ld+json">
{
  "@graph": [
    { ... your first JSON-LD block ... },{ ... your second JSON-LD block ... }
  ]
}
</script>
原文链接:https://www.f2er.com/html5/168141.html

猜你在找的HTML5相关文章