What is JSON-LD?
First, let's take a look at what JSON-LD stands for, so that we can really understand what it does.
Let's dissect it:
JSON is a lightweight data exchange format, which is easy to read and write by humans, and is easy to parse and build by machine.
Linked Data is about connecting related data using the internet.
Why use Schema.org?
What we are talking about here, is structured data for your website. Schema.org provides a way to present your information to Google in a machine readable manner. With this structured data, you create an option for Google to display your content in two categories of Google Search:
Rich results, which means your added content, such as the price of your product, its ranking, and / or availability, is literally shown in search results as additional information in your snippet.
The sitelink search box, if your site meets the requirements, the feature is already supported by our Yoast SEO plugin.
Knowledge Graph Card. This one is a little more difficult, because you have to prove first that you are an authority for certain content. After you do this, Google may include your data in the Knowledge Graph.
As you can see, it is very interesting to optimize your site using Schema.org.
Increase the chances of Google showing rich snippets from your site in search results: learn how to add structured data with our training on structured data and SEO.
The methods used to implement schema.org before JSON-LD were available are impractical. You must add the schema.org attribute to the code snippet in your markup. The markup may have to change from page to page, even if you include the same header everywhere, for example. This makes schema.org difficult to implement. For us as plugin developers (and hence back-end), it pushes completely into the front-end development realm.
You can basically add any schema to your JSON-LD block, even link traces.
In fact, in its own documentation, Google often states JSON-LD is the easiest way to add metadata to a site. These are the options that are least likely to break when you make other changes to your site.
Add scripts to your website
Fortunately, JSON + LD is set up in a standard format. Here's an example of this format for random products:
"name": "cmlabs SEO Tools",
"description": "Choose structured data for recipe, job posting and product schema and build the markup with JSON-LD Generator.",
You can use any schema.org schema in JSON-LD. After adding the new JSON-LD script to your website, make sure to validate your code using Google's structured data test tool. As you can see, this can easily be templated in your theme. There are generators like this one, which can be useful in preparing a template for it. If you are using WordPress, obviously there are plugins that can help you too.