Enabling Google Sitelinks Search Box

2.5k views Asked by At

I want to enable Google Sitelinks Search Box for a website. The point is its custom search page is implemented by hash fragment so the JSON-LD data snippet is like this:

<script type="application/ld+json">
  {
  "@context": "http://schema.org",
  "@type": "WebSite",
  "name" : "my site",
  "alternateName" : "example.com",
  "url": "http://www.example.com/",
  "potentialAction": {
    "@type": "SearchAction",
    "target": "http://www.example.com/Search/#!/Keyword-{search_term_string}",
    "query-input": "required name=search_term_string"
  }
}
</script>

While Google tries to extract the information from this part "required name=search_term_string" to show the sitelinks search box, encounter a problem:

:   http://schema.org/True
valueName:  missing and required

I suspect maybe Google just expect search string inside a query string instead of hash fragment, what do you recommend except redirecting?

1

There are 1 answers

3
Un4g1v3n On BEST ANSWER

Thanks to @unor I found the solution, so the final code is something like this:

<script type="application/ld+json">
        {
          "@context": "http://schema.org",
          "@type": "WebSite",
          "name" : "example",
          "alternateName" : "example.com",
          "url": "http://www.example.com/",
          "potentialAction": {
            "@type": "SearchAction",
            "target": "http://www.example.com/Search/#!/Keyword-{search_term_string}/",
            "query-input": {
          "@type": "PropertyValueSpecification",
          "valueRequired": true,
          "valueMaxlength": 100,
          "valueName": "search_term_string"
      }
          }
        }
</script>