Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple JSON-LD tag groups in one page

Can I use multiple JSON-LD groups (using Schema.org) in the same page?

If I can't, how to combine them together? I'm not so familiar with the syntax.

Group 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": "[email protected]",
  "faxNumber": "860-562-4250",

}
</script>

Group 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>
like image 863
wkyip Avatar asked Sep 29 '15 10:09

wkyip


2 Answers

You can either have multiple script blocks on your page or combine it in a single block. The easiest way to combine them into a single block is to use the @graph keyword as follows:

<script type="application/ld+json">
{
  "@graph": [
    { ... your first JSON-LD block ... },
    { ... your second JSON-LD block ... }
  ]
}
</script>
like image 92
Markus Lanthaler Avatar answered Nov 13 '22 06:11

Markus Lanthaler


According to the spec (https://www.w3.org/TR/json-ld/#h3_advanced-context-usage) the usage of several contexts is possible with a simple list of contexts:

[
  {
    "@context": "http://example.org/contexts/person.jsonld",
    "name": "Manu Sporny",
    "homepage": "http://manu.sporny.org/",
    "depiction": "http://twitter.com/account/profile_image/manusporny"
  },
  {
    "@context": "http://example.org/contexts/place.jsonld",
    "name": "The Empire State Building",
    "description": "The Empire State Building is a 102-story landmark in New York City.",
    "geo": {
      "latitude": "40.75",
      "longitude": "73.98"
    }
  }
]
like image 41
hsrv Avatar answered Nov 13 '22 07:11

hsrv