最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Sitelinks Search box schema confusion

programmeradmin8浏览0评论

Trying to implement Sitelinks Search box schema in order to help Google show a search-box above my sitelinks I realized there is some confusion (for a newbie) in the current documentation I could find.

This is the example provided by Google

  "@context": "",
  "@type": "WebSite",
  "url": "/",
  "potentialAction": {
    "@type": "SearchAction",
    "target": "={search_term_string}",
    "query-input": "required name=search_term_string"
  }

First of all, for WP, we should replace the ?q with ?s

However there are more questions

1. Use search_term_string or search_term

Reading the code provided in some helpful articles on the web and even the code of some plugins, almost half of them use search_term instead of search_term_string. Which one should I use? Are both correct? Is WP actually using these expressions in their core?

2. Testing the code

Google (which is the reason we care about the searchbox in the first place) suggest this type of testing your markup:

...if your website is example, and you want to test the query "kittens", you would browse to /?q={kittens}

Ignoring the fact that it uses ?q instead of ?s this test is not successful for any of the found solutions. As this is how WP search url looks like:

/?s=kittens

The question is: Can I use either of search_term_string or search_term, forget about google test query and move on?

Trying to implement Sitelinks Search box schema in order to help Google show a search-box above my sitelinks I realized there is some confusion (for a newbie) in the current documentation I could find.

This is the example provided by Google

  "@context": "http://schema",
  "@type": "WebSite",
  "url": "https://www.example/",
  "potentialAction": {
    "@type": "SearchAction",
    "target": "https://query.example/search?q={search_term_string}",
    "query-input": "required name=search_term_string"
  }

First of all, for WP, we should replace the ?q with ?s

However there are more questions

1. Use search_term_string or search_term

Reading the code provided in some helpful articles on the web and even the code of some plugins, almost half of them use search_term instead of search_term_string. Which one should I use? Are both correct? Is WP actually using these expressions in their core?

2. Testing the code

Google (which is the reason we care about the searchbox in the first place) suggest this type of testing your markup:

...if your website is example, and you want to test the query "kittens", you would browse to https://www.example/search/?q={kittens}

Ignoring the fact that it uses ?q instead of ?s this test is not successful for any of the found solutions. As this is how WP search url looks like:

https://www.example/search/?s=kittens

The question is: Can I use either of search_term_string or search_term, forget about google test query and move on?

Share Improve this question edited Nov 9, 2017 at 22:33 fuxia 107k38 gold badges255 silver badges459 bronze badges asked Nov 9, 2017 at 14:35 IXNIXN 9362 gold badges11 silver badges31 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Without getting into the structured data itself, it is important to remember that the actual url on which wordpress will run the search has to be the home page. If you are using "pretty permalinks" wordpress will probably try to parse the url as content, not as search for almost anything that is not the home page. So you target URL should probably be example/?s= .

The other thing that looks fishy is the use of "{}". If google sends it and not just use it for parameter formatting, than you should not use it as it will most likely break the wordpress search (or more accurate, you will not get results).

As for the structure itself, it seems like the name you use for the parameter is not important by itself, as long as you use the same string the two attributes in which it is being specified and used.

发布评论

评论列表(0)

  1. 暂无评论