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:
<html>
<head>
<title>Article headline</title>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "NewsArticle",
"headline": "Article headline",
"image": [
"https://example.com/photos/1x1/photo.jpg",
"https://example.com/photos/4x3/photo.jpg",
"https://example.com/photos/16x9/photo.jpg"
],
"datePublished": "2015-02-05T08:00:00+08:00",
"dateModified": "2015-02-05T09:20:00+08:00",
"author": [{
"@type": "Person",
"name": "Jane Doe",
"url": "http://example.com/profile/janedoe123"
},{
"@type": "Person",
"name": "John Doe",
"url": "http://example.com/profile/johndoe123"
}]
}
</script>
</head>
<body>
</body>
</html>