Google 结构化数据测试工具无法将类型验证为 JSON-LD 中 @type 的别名,上下文为 schema.org
Google Structured Data Testing Tool fails to validate type as an alias of @type in JSON-LD with schema.org context
如果您使用例如lanthaler/JsonLD 使用 schema.org
上下文压缩 JSON-LD 数据,您会注意到 @type
关键字在输出中被替换为别名 type
,这是有道理的鉴于
Schema.org recently added a keyword alias from @type to just type
问题是 Google 的 Structured Data Testing Tool 无法识别此别名。这是一个简单的例子来证明这一点(尝试将 type
替换为 @type
,它将通过验证)
{
"@context": "http://schema.org",
"type": "Product",
"name": "SomeName"
}
这提出了几个问题:
- 测试工具无法验证此有效标记是否意味着 google 将忽略它,并且不会影响搜索结果中的显示?
- 如果是这样,有没有办法强制
lanthaler/JsonLD
避免在压缩过程中用type
替换@type
(理想情况下没有任何其他副作用)?
回答你的第二个问题:是的,通过使用不同的上下文。例如以下内容:
{
"@context": {
"@vocab": "http://schema.org/"
}
}
这 context ends up in the result 但这很好,因为 SDTT 能够处理它。
如果您使用例如lanthaler/JsonLD 使用 schema.org
上下文压缩 JSON-LD 数据,您会注意到 @type
关键字在输出中被替换为别名 type
,这是有道理的鉴于
Schema.org recently added a keyword alias from @type to just type
问题是 Google 的 Structured Data Testing Tool 无法识别此别名。这是一个简单的例子来证明这一点(尝试将 type
替换为 @type
,它将通过验证)
{
"@context": "http://schema.org",
"type": "Product",
"name": "SomeName"
}
这提出了几个问题:
- 测试工具无法验证此有效标记是否意味着 google 将忽略它,并且不会影响搜索结果中的显示?
- 如果是这样,有没有办法强制
lanthaler/JsonLD
避免在压缩过程中用type
替换@type
(理想情况下没有任何其他副作用)?
回答你的第二个问题:是的,通过使用不同的上下文。例如以下内容:
{
"@context": {
"@vocab": "http://schema.org/"
}
}
这 context ends up in the result 但这很好,因为 SDTT 能够处理它。