我必须注射多个script
JSON-LD 数据的元素到head
我的申请,全部都属于同一@type
。这是由于从不同的数据源提取不同的字段。
这种重复会导致任何问题吗?
<script type="application/ld+json">
{
"@type": "Organisation",
"name": "John Smith"
}
</script>
<script type="application/ld+json">
{
"@type": "Organisation",
"city": "London"
}
</script>
我希望谷歌能将其简单地翻译为:
<script type="application/ld+json">
{
"@type": "Organisation",
"name": "John Smith",
"city": "London"
}
</script>
是对的吗?
消费者不能/不应该假设这些 JSON 对象描述相同的事物。 (想象一个包含许多不同组织信息的网页:假设它们是同一组织当然是错误的。)
JSON-LD 允许您指定不同对象中描述的事物是相同的:给它们相同的@id
value.
@id
采用 IRI 作为标识符(它是出于多种原因提供它们很有用).
See 节点标识符在 JSON-LD 规范中。
所以它可能看起来像这样(使用 Schema.org 而不是您的自定义词汇表):
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Organization",
"@id": "/organizations/42#this",
"name": "ACME"
}
</script>
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Organization",
"@id": "/organizations/42#this",
"description": "…"
}
</script>
(相对网址/organizations/42#this
将代表组织本身。最佳实践是提供此 JSON-LD 以及您有关该组织的信息/organizations/42
.)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)