Un4g1v3n
Un4g1v3n

Reputation: 426

Enabling Google Sitelinks Search Box

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?

Upvotes: 2

Views: 2755

Answers (1)

Un4g1v3n
Un4g1v3n

Reputation: 426

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>

Upvotes: 6

Related Questions