Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you combine several JSON-LD markups?

Tags:

json

html

json-ld

I'm finding it difficult to merge couple or several JSON-LD markups together being a novice. Could you please tell me what I'm doing wrong?

When I enter the following markup into Google Structured Data Testing Tool, it only shows results for the Organization schema type while there's BreadcrumbList type too.

<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Organization",
"legalName": "Example INC",
"logo": "https://www.example.com/image.png",
"url": "https://www.example.com/",
"sameAs": [
"https://www.facebook.com/example",
"https://www.linkedin.com/company/example",
"https://twitter.com/example",
"https://www.youtube.com/user/example",
"https://en.wikipedia.org/wiki/example"
]
}
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": "1",
"item": {
"@id": "https://www.example.com/",
"name": "Homepage" 
}
}
]
</script>
like image 598
Iam_Amjath Avatar asked Jan 17 '18 06:01

Iam_Amjath


1 Answers

For specifying multiple top-level items, you have three options:

Array

<script type="application/ld+json">
[
  {
     "@context": "http://schema.org",
     "@type": "Organization"
  },
  {
     "@context": "http://schema.org",
     "@type": "BreadcrumbList"
  }
]
</script>

Drawback: You have to repeat the @context for each item.

@graph

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@graph": 
  [
    {
       "@type": "Organization"
    },
    {
       "@type": "BreadcrumbList"
    }
  ]
}
</script>

Multiple script elements

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Organization"
}
</script>

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "BreadcrumbList"
}
</script>

Drawback: You have to repeat the script element and the @context for each item.


But it’s typically preferable to provide only one top-level item, and nest the additional items under suitable properties. This is not possible in all cases, though.

In your case it seems to be possible by adding a WebPage item, assuming it’s the organization’s page and this page has this breadcrumb list:

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "WebPage",
  "provider": 
  {
    "@type": "Organization"
  },
  "breadcrumb": 
  {
    "@type": "BreadcrumbList"
  }
}
</script>

(You can achieve the same without nesting: give each item a URI with @id, and then reference these URIs as property values.)

like image 64
unor Avatar answered Sep 20 '22 20:09

unor