: Linking external JSON-LD schema (from Schema.org) I have schemas in JSON-LD as per Schema.org. When it was inline (within <script> tags), the Google structured data testing tool recognised
I have schemas in JSON-LD as per Schema.org. When it was inline (within <script> tags), the Google structured data testing tool recognised the schema successfully.
If I link it externally, for example: <script src="json/main-schema.json" type="application/ld+json"></script> the structured data testing tool doesn't recognise it.
Is this something I should be worried about?
How I had the working schema (example from Schema.org):
<script type="application/ld+json">
{ "@context" : "http://schema.org",
"@type" : "Organization",
"url" : "http://www.your-company-site.com",
"contactPoint" : [
{ "@type" : "ContactPoint",
"telephone" : "+1-401-555-1212",
"contactType" : "customer service"
} ] }
</script>
External schema layed out in main-schema.json, linked with <script src="json/main-schema.json" type="application/ld+json"></script>:
{ "@context" : "http://schema.org",
"@type" : "Organization",
"url" : "http://www.your-company-site.com",
"contactPoint" : [
{ "@type" : "ContactPoint",
"telephone" : "+1-401-555-1212",
"contactType" : "customer service"
} ] }
More posts by @Welton855
2 Comments
Sorted by latest first Latest Oldest Best
unor’s answer sums it up, but I also want to add:
From the spec:
Setting the [type] attribute to any other value [other than a JavaScript MIME type] means that the script is a data block, which is not processed. None of the <script> attributes (except type itself) have any effect on data blocks. Authors must use a valid MIME type that is not a JavaScript MIME type to denote data blocks.
So, in other words, if you have a <script> with a type attribute set to anything other than text/javascript (or an equivalent JavaScript MIME type), then all attributes, including src, will have no effect.
The script element can be used for two things:
dynamic/classic scripts
data
And for data, the spec defines:
When used to include data blocks, the data must be embedded inline […]
So you may use the src attribute only for scripts, not for data.
→ As JSON-LD is data, you have to inline it.
While linking a JSON-LD file is possible with the link element, the Schema.org sponsoring search engines don’t seem to support it.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.