Mobile app version of vmapp.org
Login or Join
Sent6035632

: Where is the ideal place in code to use Schema.org markup as JSON-LD? Where is the best place to put Schema.org markup that uses JSON-LD? Some recommend inside <head> but scripts work

@Sent6035632

Posted in: #JsonLd #Microdata

Where is the best place to put Schema.org markup that uses JSON-LD? Some recommend inside <head> but scripts work inline too. It would be easier in an MVC to put them in the same scope as the controllers, so that means inline near their element. But JSON-LD may "work better" as one huge script/stack in the <head>. I am just unsure of the ideal location I suppose.

Example would be breadcrumbs - should I just put the JSON-LD script before the markup for the crumbs, or should I go through all the trouble of loading up the models (again) to define them in the area creating the <head>? Seems like it would be a performance hit, but if its worth it for the spec, then it needs to be done.

Here is an example of Organization in JSON-LD (this would be in <head> already):

<script type="application/ld+json"> {
"@context" : "http://schema.org",
"@type" : "Organization",
"name" : "A Huge Corporation",
"url" : "http://www.example.com",
"logo" : "http://www.example.com/huge-corporation.png",
"founder" : "Humanz",
"foundingDate" : "1268",
"sameAs" : "http://plus.google.com/111111111111111111111",
"contactPoint" : {
"@type" : "ContactPoint",
"contactType" : "Customer Service",
"telephone" : "+1-888-888-8888",
"faxNumber" : "+1-777-777-7777",
"contactOption" : "TollFree",
"areaServed" : "US",
"availableLanguage" : "English",
"email" : "dude@example.com"
},
"hasPos" : {
"@type" : "Place",
"name" : "The Branch or Store",
"photo" : "http://www.example.com/store.png",
"hasMap" : {
"@type" : "Map",
"url" : "https://maps.google.com/maps?q=feed_me_a_map"
},
"address" : {
"@type" : "PostalAddress",
"name" : "The Branch or Store",
"streetAddress" : "1547 Main Street",
"addressLocality" : "Beverly Hills",
"addressRegion" : "CA",
"postalCode" : "90210",
"addressCountry" : "United States"
}
}}
</script>


And here is the breadcrumb snippet (currently resides in another scope, further down the page near the visually rendered crumbs). Would be nice to get this in head, if the work is worth it:

<script type="application/ld+json"> {
"@context" : "http://schema.org",
"@type" : "Breadcrumblist",
"itemListElement" : [
{
"@type" : "ListItem",
"position" : 1,
"item" : {
"@id" : "http:www.example.com",
"name" : "Home"
}
},
{
"@type" : "ListItem",
"position" : 2,
"item" : {
"@id" : "http:www.example.com/widgets",
"name" : "Widgets"
}
},
{
"@type" : "ListItem",
"position" : 3,
"item" : {
"@id" : "http:www.example.com/widgets/green",
"name" : "Green Widgets"
}
}
]}
</script>

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Sent6035632

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ann8826881

JSON-LD doesn’t care. Which makes sense, because the data is the same, no matter from where in the document it gets extracted.

From the perspective of HTML, you should only include it in the head if the JSON-LD is about your web page or about what your web page represents, because the head element is defined to contain metadata for the document. But it’s not always easy to define if something counts as metadata or not; I wouldn’t worry too much about this.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme