What's a `<script type='application/ld+json'>{jsonObj}</script>` in a `head` section do?

Asim K T picture Asim K T · Jul 30, 2016 · Viewed 53.9k times · Source

I got this link but didn't understand well. Saw:

<script type="application/ld+json">
{
    "@context": "http://schema.org",
    "@type": "WebSite",
    "url": "http://website.com",
    "name": "wbs",
    "description": "Web Studio"
}
</script>

in a source code.

How a code snippet like above in my website header help me or my site?

Answer

unor picture unor · Aug 3, 2016

In your example, the script element is used as data block, which contains JSON-LD (type="application/ld+json").

JSON-LD is a RDF serialization. It allows you to publish Linked Data (or structured data) using JSON. In your example, the vocabulary Schema.org is used ("@context": "http://schema.org").

This structured data can be used by any interested consumer. Prominent consumers are the search engines Bing, Google, Yahoo, and Yandex, which support structured data that uses the vocabulary Schema.org. One use case they have is displaying more details in their result snippets.

Your example probably doesn’t lead to such an enhanced snippet. You have to check the search engine’s documentation if you want to know what features they offer and which structured data you have to provide for these. For example, Google uses the WebSite type (that’s used in your example) for their Sitelinks Search Box, but you would have to add a potentialAction in addition (for the search function).