问题
We are implementing search box within the search result in Google for our site. We have our own search feature on website, and dont want to use Google custom search.
We are following instructions on the following page, but finding it difficult to set it up. Google developer site.
I added the following JSON-LD in the head, but it is not working
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"url": "http://www.oursite.com.au/",
"potentialAction": {
"@type": "SearchAction",
"target": "http://www.oursite.com.au/search.aspx?keyword={search_term}",
"query-input": "required name=search_term"
}
</script
I was wondering if I set up the code correctly?
回答1:
There is one possible error with your syntax, which is that you are missing a last closing bracket. Your script is also not closed properly as well. I'm guessing it is possible both of these issues could be from copying into SO.
For good measure, it should look like:
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebSite",
"url": "http://www.oursite.com.au/",
"potentialAction": {
"@type": "SearchAction",
"target": "http://www.oursite.com.au/search.aspx?keyword={search_term}",
"query-input": "required name=search_term"
}
}
</script>
After that, can you confirm the following:
- http://www.oursite.com.au/search.aspx?keyword=test would successfully perform a search on your site for the term "test"? Per the spec does that search sit on the same domain you have the code on?
- Have you allowed your site enough time to index after making these changes?
来源:https://stackoverflow.com/questions/25754392/google-sitelink-search-box