background img
Jun 10, 2019
205 Views

How to Combine & Nest Multiple JSON-LD Schema Types With @Graph

Written by

When attempting to add multiple entries of the same type into JSON-LD structured data, it can be a little tricky. If you use a separate script tag for each entry, the Google Structured Validation tool will return an error related to “an expected array” if you copy the full source code of the page the schema is entered on and paste it into the tool in the Code Snippet box. If you simply paste only the schema code into the Code Snippet box in the tool, it won’t return an error and the multiple Organization entries will show (if you are adding in multiple Organization-type schema of course). Below are two images that show what I am referring to:

 

Why Nest Multiple JSON-LD Schema Types?

There are two specific use cases for nesting schema entries that I can think of. In my use case, I wanted to add schema to different non-profit organizations and locations that I listed on a city page to add additional location relevance to that page. This could sort of be considered a “directory” method. I noticed that competitors in my niche had directory websites that were ranking well and so properly adding schema to these business addresses was a piece of the puzzle in recreating this type of strategy. Nesting Local Business schema could also be necessary if you have several locations for your business on a page on your business’ website.

Nesting Multiple Schema Types into One Script Tag

It is interesting that although the tool does recognize all the individual Organization entries in this example, it still returns an error. Without the error, however, it would still be an inefficient way of creating multiple entries in JSON-LD as you are repeating the opening and closing Script tag each time. It took some playing around with but I was able to locate a way to do just this without returning any errors using @graph. Essentially, you are containing all the entries inside of the @graph brackets. In addition, you are adding a comma at the end of each closing curly bracket for each entry which implies in JSON-LD that another entry is going to follow, almost like a list of sorts. Of course, after the last closing curly bracket that closes the last Organization entry, Lancaster-Fairfield Community Action Agency in this case, there is no comma.

You can see how this is done below. If you copy this code into the Google Structured Data Validation tool, it won’t return the Uncategorized Error shown in the images above whether you paste just the schema code or the full source code of the page into the Code Snippet box in the tool. 

 

<script type=’application/ld+json’>

{
“@context”: “http://www.schema.org”,

@graph”: [

{
“@type”: “Organization”,
“name”: “Canal Winchester Asbury 12 and 12 Group”,
“address”: {
“@type”: “PostalAddress”,
“streetAddress”: “80 W. Winchester Sobriety Checkpoint”,
“addressLocality”: “Canal Winchester”,
“addressRegion”: “OH”,
“postalCode”: “43110”,
“addressCountry”: “United States”
}
},

{
“@type”: “Organization”,
“name”: “Canal Winchester Sobriety Checkpoint”,
“address”: {
“@type”: “PostalAddress”,
“streetAddress”: “28 Elm St.”,
“addressLocality”: “Canal Winchester”,
“addressRegion”: “OH”,
“postalCode”: “43110”,
“addressCountry”: “United States”
}
},

{
“@type”: “Organization”,
“name”: “Family Church”,
“address”: {
“@type”: “PostalAddress”,
“streetAddress”: “13475 Tollgate Rd.”,
“addressLocality”: “Pickerington”,
“addressRegion”: “OH”,
“postalCode”: “43147”,
“addressCountry”: “United States”
}
},

{
“@context”: “http://www.schema.org”,
“@type”: “Organization”,
“name”: “St. Andrews”,
“address”: {
“@type”: “PostalAddress”,
“streetAddress”: “8630 Refugee Rd.”,
“addressLocality”: “Pickerington”,
“addressRegion”: “OH”,
“postalCode”: “43147”,
“addressCountry”: “United States”
}
},

{
“@context”: “http://www.schema.org”,
“@type”: “Organization”,
“name”: “Beckett Springs Hospital”,
“address”: {
“@type”: “PostalAddress”,
“streetAddress”: “8614 Shepherd Farm Dr.”,
“addressLocality”: “West Chester”,
“addressRegion”: “OH”,
“postalCode”: “45069”,
“addressCountry”: “United States”
}
},

{
“@context”: “http://www.schema.org”,
“@type”: “Organization”,
“name”: “Lindner Center of Hope”,
“address”: {
“@type”: “PostalAddress”,
“streetAddress”: “4057 Western Row Rd. “,
“addressLocality”: “Mason”,
“addressRegion”: “OH”,
“postalCode”: “45040”,
“addressCountry”: “United States”
}
},

{
“@context”: “http://www.schema.org”,
“@type”: “Organization”,
“name”: “Al-Anon David’s United Church of Christ”,
“address”: {
“@type”: “PostalAddress”,
“streetAddress”: “80 West Columbus St.”,
“addressLocality”: “Canal Winchester”,
“addressRegion”: “OH”,
“postalCode”: “43110”,
“addressCountry”: “United States”
}
},

{
“@context”: “http://www.schema.org”,
“@type”: “Organization”,
“name”: “New Horizons Mental Health”,
“address”: {
“@type”: “PostalAddress”,
“streetAddress”: “1592 Granville Pike”,
“addressLocality”: “Lancaster”,
“addressRegion”: “OH”,
“postalCode”: “43130”,
“addressCountry”: “United States”
}
},

{
“@context”: “http://www.schema.org”,
“@type”: “Organization”,
“name”: “Fairfield County ADAMH Board”,
“address”: {
“@type”: “PostalAddress”,
“streetAddress”: “108 W. Main St., Suite A”,
“addressLocality”: “Lancaster”,
“addressRegion”: “OH”,
“postalCode”: “43130”,
“addressCountry”: “United States”
}
},

{
“@context”: “http://www.schema.org”,
“@type”: “Organization”,
“name”: “Fairfield County Family, Adult and Children First Council”,
“address”: {
“@type”: “PostalAddress”,
“streetAddress”: “831 College Avenue Suite C”,
“addressLocality”: “Lancaster”,
“addressRegion”: “OH”,
“postalCode”: “43130”,
“addressCountry”: “United States”
}
},

{
“@context”: “http://www.schema.org”,
“@type”: “Organization”,
“name”: “Lancaster-Fairfield Community Action Agency”,
“address”: {
“@type”: “PostalAddress”,
“streetAddress”: “1743 East Main St.”,
“addressLocality”: “Lancaster”,
“addressRegion”: “OH”,
“postalCode”: “43130”,
“addressCountry”: “United States”
}
}

]
}

</script>

Conclusion

It took me several hours to get this down as it took some research and much trial and error but I hope this is helpful for you! Let me know if you have any questions below.

Article Tags:
Article Categories:
Internet Marketing
 

Leave a Reply

Your email address will not be published. Required fields are marked *

Dennis Camilo
LeverageLifestyle