Looking through Google's suggestions of search optimisation for a site that I control, I would like to add their "Structured Data" JSON to various pages on the site. Their suggestion is to include the data in custom script tags:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Organization",
"url": "http://website.com",
"logo": "http://website.com/logo.png",
"contactPoint": [{
"@type": "ContactPoint",
"telephone": "+44 1234 567890",
"contactType": "customer service"
}]
}
</script>
What I can't work out is how to include this data "the Drupal way". I tried adding it as a library (thinking I'd later use DrupalSettings to customise the contents) but that includes it as a standard "type=javascript". How do I add it to the page header with the correct script type?
Google ref: https://developers.google.com/search/docs/data-types/corporate-contact
(answers giving a module that does this already are also welcome!)