1

Let's say we have an ecommerce like Adidas. We have the basic JSON-LD structure for the WebSsite:

{
  "@context": "http://schema.org",
  "@type": "WebSite",
  "url": "https://adidas.com/us",
  "potentialAction": {
    "@type": "SearchAction",
    "target": "https://adidas.com/us/search?q={search_term_string}",
    "query-input": "required name=search_term_string"
  }
}

We have the Organization:

{
  '@context': 'http://schema.org',
  '@type': 'Organization',
  'name': 'Adidas',
  'description': 'Sport Shop',
  'email': 'adidas@adidas.us',
  'url': 'http://www.adidas.us',
  'logo': 'http://www.adidas.us/logo.svg'
}

The website is also a Store:

 "@context":"http://schema.org",
 "@type":"Store",
 "url": 'http://www.adidas.us',
 "description": "Adidas Shop !",
 "name": "Adidas"
}

And we have also the classic BreadcrumbList:

 "@context":"http://schema.org",
 "@type":"BreadcrumbList",
 "itemListElement":
  [  
    {  
       "@type":"ListItem",
       "position":1,
       "item":{  
          "@type":"Thing",
          "@id":"https://www.adidas.us",
          "name":"Adidas"
       }
    },
    {  
       "@type":"ListItem",
       "position":2,
       "item":{  
          "@type":"Thing",
          "@id":"https://www.adidas.us/shoes",
          "name":"Adidas shoes"
       }
    },
    {  
       "@type":"ListItem",
       "position":3,
       "item":{  
          "@type":"Thing",
          "@id":"https://www.adidas.us/shoes/Featured",
          "name":"Adidas featured shoes"
       }
    }
  ]
}

These 3 JSON-LD are common (more or less detailed of course), and sometimes I have found in a webpage 3 script elements with these JSON-LD, sometimes just 1, sometimes 2.

Should we try to nest them into one single script (if so, how !?), or is it better to keep them splitted?

Héctor León
  • 2,210
  • 2
  • 23
  • 36

1 Answers1

1

Important is that you connect the entities with suitable properties, not how many script elements you use.

If you have these three entities on a page, you should convey how they are related. What you probably want to convey: there is a web page that is part of that website, that is published by that organization, and that has that a breadcrumb list.

So what you are missing is an entity representing the web page (→ WebPage) and properties to connect all your entities (→ publisher, breadcrumb, isPartOf).

In how many script elements you specify these entities is up to you:

  • One script, nesting all entites.
  • One script, with multiple top-level objects (using @graph and @id).
  • A script per entity (using @id).
  • A combination of the above.

The first one is the most simple:

{
  "@context": "http://schema.org",
  "@type": "WebPage",
  "isPartOf": {
    "@type": "WebSite"
  },
  "publisher": {
    "@type": "Organization"
  },
  "breadcrumb": {
    "@type": "BreadcrumbList"
  }
}

Give each relevant entity an @id, so you can reference these entities on the same page (in the same script element or in other ones), or even on external pages.

I’m using it here to convey that the same Organization is the publisher of the WebPage as well as the WebSite:

{
  "@context": "http://schema.org",
  "@type": "WebPage",
  "@id": "",
  "isPartOf": {
    "@type": "WebSite",
    "@id": "/#this-site",
    "publisher": {"@id": "/#this-org"}
  },
  "publisher": {
    "@type": "Organization",
    "@id": "/#this-org"
  },
  "breadcrumb": {
    "@type": "BreadcrumbList"
  }
}
unor
  • 92,415
  • 26
  • 211
  • 360
  • Ok this is awesome. thank you so much @unor. So hard to find detailed info about this. So following your last snippet how could we add 'Store' @type I have seen passing an arr of types`"@type": ["Website", "Store"]` Is this a good way to do it? Or we can add "Store" as a new key under `"Breadcrumb"` And Adidas Store is also a "ShoeStore"... `"@type": ["Website", "Store", "ShoeStore"]`? As u can see, the confuse part to me is this nesting. Webpage has also a key specialty (One of the domain specialities to which this web page's content applies) `"specialty" : { @type: "Store" }` – Héctor León May 31 '18 at 11:04
  • 1
    @HéctorLeón: While you *could* add data to the `BreadcrumbList` structure, I wouldn’t do it (consumers might skip the whole item if they are not interested in breadcrumbs). -- There are various ways how `Store` could be connected -- it depends on your exact use case (to answer this, more details are needed; might warrant a new question; if only asking about which property to use, probably best at [webmasters.se]). -- By the way: If it’s a `ShoeStore`, you don’t have to specify `Store` in addition, because `ShoeStore` has `Store` as parent type. – unor May 31 '18 at 11:17
  • And one more question, why the slash / before the hashtag ? in the `"@id": "/#ID-HERE"` – Héctor León May 31 '18 at 11:29
  • Oh thanks, so am not forcing to specify parent, they just inherit his parent properties. Nice thanks again, i will join to that community and post then a new question :) – Héctor León May 31 '18 at 11:31
  • 1
    @HéctorLeón: The goal is to specify a URI that represents the actual thing, not just a page where this thing is described; the `#` helps to disambiguate ([details](https://stackoverflow.com/a/16017139/1591669)). So for a website at `https://example.com/`, specifying `"@id": "/#this-org"` somewhere, the resulting URI would be: `https://example.com/#this-org`. Whenever you mention this organization in your structured data, you should specify this URI. Now, that’s just an example -- you can use whatever URI you want, of course (`/organization#this`, `/foobar552#organization` etc.). – unor May 31 '18 at 11:38