附加链接搜索框 JSON-LD 在 Google 结构化数据测试工具上给出错误

Sitelinks Search Box JSON-LD giving error on Google Structured Data Testing Tool

我实现了 Google 的 Sitelinks Search Box to my site. It was working very well. But today I cheked again on Google Structured Data Testing Tool,但是出了点问题。现在我遇到以下错误:

我的实现是:

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "WebSite",
  "url": "https://www.saatler.com/",
  "potentialAction": {
    "@type": "SearchAction",
    "target": "https://www.saatler.com/arama?ara={search_term_string}",
    "query-input":"required name=search_term_string"
  }
}
</script>

当我检查 the JSON-LD playground 上的 JSON 时,一切看起来都很好。我没有更改我网站上的任何内容。 Google 这个问题有错吗?或者 Schema.org 结构发生了变化?我应该怎么做才能解决这两个问题?

我注意到即使是在线示例 documentation 也会收到与您收到的完全相同的错误。当我改变

"@context": "http://schema.org"

"@context": "http://schema.org/true"

错误消失了。希望这可以帮助。

<script type="application/ld+json">
{
  "@context": "http://schema.org/true",
  "@type": "WebSite",
  "url": "https://www.saatler.com/",
  "potentialAction": {
    "@type": "SearchAction",
    "target": "https://www.saatler.com/arama?ara={search_term_string}",
    "query-input":"required name=search_term_string"
  }
}
</script>

通过查看 schema.org Potential Actions page 找到答案。

显然,无论出于何种原因,Google 的 Structured Data Testing Tool 不喜欢我们用于输入和输出文本表示的简写版本。

当我切换到详细版本时,我得到了 WebSite (1) 的正确复选标记,而不是 http://www.example.com/Website (1)。

Textual representations of Input and Output

For convenience, we also support a textual short-hand for both of these types that is formatted and named similarly to how they would appear in their HTML equivalent. For example:

"<property>-input": {
  "@type": "PropertyValueSpecification",
  "valueRequired": true,
  "valueMaxlength": 100,
  "valueName": "q"
}

Can also be expressed as:

<property>-input: "required maxlength=100 name=q"

这是我们的完整代码,供任何其他尝试遵循此代码的人使用:

<script type="application/ld+json">
{

  "@context": "http://schema.org",
  "@type": "WebSite",
  "name" : "Example Company",
  "url": "http://www.example.com/",
  "sameAs" : [ "https://www.facebook.com/pages/Example/###############",
    "https://plus.google.com/b/#####################/#####################"],
  "potentialAction": {
    "@type": "SearchAction",
    "target": "http://www.example.com/search/results/?q={q}",
    "query-input": {
        "@type": "PropertyValueSpecification",
        "valueRequired": true,
        "valueMaxlength": 100,
        "valueName": "q"
    }
  }
}
</script>

was a bug 在 Google 结构化数据测试工具中。

现在已修复:该工具不再报告您的标记错误。