SEO - Structured data in JSON-LD format

How to add a script in header for a specific page? This can be useful to add structured data to a page displaying a blog post for example (Learn About Article Schema Markup | Google Search Central | Documentation | Google Developers), a recipe, a product, etc. The structured data snippet should be set in the header per page. For now, I only see that when we add a script in the header, it will be applied to all pages. Example of a structured data in the header section:

	    <title>Article headline</title>
	    <script type="application/ld+json">
	      "@context": "",
	      "@type": "NewsArticle",
	      "headline": "Article headline",
	      "image": [
	      "datePublished": "2015-02-05T08:00:00+08:00",
	      "dateModified": "2015-02-05T09:20:00+08:00",
	      "author": [{
	          "@type": "Person",
	          "name": "Jane Doe",
	          "url": ""
	          "@type": "Person",
	          "name": "John Doe",
	          "url": ""

Hi! It’s not mandatory to add the structured data (schema) in the header.
You can read more on how to add a schema on this related topic: for Sitejet - #8 by Lucian_Dinu

Hope this helps!

1 Like

Hi @Lucian_Dinu, thank you for your reply.

As far as I know and based on the Google Documentation, generally there are 2 ways of setting up the structured data:

  1. JSON-LD in the head tag
  2. Micodata in the body tag

And according to your answer, you are saying that I should use HTML tag element in the page body and populate it with JSON-LD code. I cannot see any Google Structured Data documentation that suggests this way. Please share your source if you found this.

Hi @AJ_Joe , the info is also in the Google Structured Data documentation.

Take a look here: Understand How Structured Data Works | Google Search Central  |  Documentation  |  Google Developers

Hope this helps!

P.S. You can also use this tool to check your Schema Schema Markup Testing Tool | Google Search Central  |  Google Developers

1 Like

Hi @Lucian_Dinu, thank you very much for pointing this out. Good to know about it.

So I would go with inserting the HTML element before the closing body tag (</body>), in other word, right after the footer but not including in the footer (as it is per page): have you implemented it this way?

But I would keep the idea of having the possibility to add a custom header code par page.

I see that you have requested a feature that may resolve this: Dedicated <head> script area. I up voted and added the request of defining head script per page.