放置使用JSON-LD的Schema.org标记的最佳位置在哪里?一些建议在里面,<head>
但是脚本也可以内联。在MVC中,将它们放置在与控制器相同的作用域中会更容易,因此意味着在其元素附近内联。但是JSON-LD作为“脚本”中的一个巨大脚本/堆栈可能会“更好地工作” <head>
。我只是不确定我认为的理想位置。
例如面包屑-我应该将JSON-LD脚本放在面包屑的标记之前,还是应该解决所有麻烦(再次)加载模型以在创建区域中定义它们<head>
?似乎会影响性能,但是如果它值得规格支持,则需要完成。
这是JSON-LD中的Organization示例(<head>
已经存在):
<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>
这是面包屑片段(当前位于另一个作用域中,在页面下方,靠近视觉呈现的碎屑)。如果这项工作值得的话,将这个想法付诸实践会很好:
<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>