How to implement JSON-LD?

1.5k views Asked by At

I’ve been reading about JSON-LD today and I understand its purpose, format, and that I can put it in a script tag; however, I don’t understand the following:

  1. Where can this data reside other than in a script tag for a website? I've been expecting to find JSON-LD content in either script tags or included .json files when I view the page source of websites that say they use JSON-LD, but since I haven't seen any of this, it leads me to believe it must be accessible in a different location.

  2. How is this collection of information usually constructed for larger websites?

  3. How do other sites find the JSON-LD files, objects, or data to use that information?

It would be really great to see an example in the wild.

2

There are 2 answers

0
Rob On

I believe you are asking where to put it on your web site's page. It would reside in between <script></script> in the <head> which is as simple as it gets.

Here is the source of all information JSON-LD

0
unor On

In HTML5, the script element can be used as data block:

When used to include data blocks (as opposed to scripts), the data must be embedded inline, the format of the data must be given using the type attribute, the src attribute must not be specified, and the contents of the script element must conform to the requirements defined for the format used.

So a script element containing JSON-LD could look like this:

<script type="application/ld+json">
    {
     "@context": "http://example.com",
     "@type": "Example"
    }
</script>

You may place the script element(s) in the head and/or in the body.