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

南笙酒味 提交于 2019-12-12 08:25:22

问题


I implemented Google’s Sitelinks Search Box to my site. It was working very well. But today I cheked again on Google Structured Data Testing Tool and something was wrong. Now I’m getting below error:

And my implementation is:

<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>

When I check the JSON on the JSON-LD playground everything is looking good. I didn’t change anything on my site. Is Google wrong about this issue? Or the Schema.org structure has changed? What should I do to fix these 2 problems?


回答1:


I noticed that even the examples on the online documentation receive the same exact error you received. When I changed

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

to

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

the error disappeared. Hope this helps.

<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>



回答2:


Found the answer by reviewing the schema.org Potential Actions page.

Apparently, for whatever reason, Google’s Structured Data Testing Tool doesn’t like our short-hand version for textual representations of input and output.

When I switched to the verbose version I get the good checkmark for WebSite (1), not 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"

Here is our full code for anyone else trying to follow this:

<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>



回答3:


It was a bug in the Google Structured Data Testing Tool.

It’s fixed now: the tool reports no more errors for your markup.



来源:https://stackoverflow.com/questions/30780247/sitelinks-search-box-json-ld-giving-error-on-google-structured-data-testing-tool

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!