Sitelinks Search box schema confusion

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.org",
  "@type": "WebSite",
  "url": "https://www.example.com/",
  "potentialAction": {
    "@type": "SearchAction",
    "target": "https://query.example.com/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.com, and you want to test the query "kittens", you would browse to https://www.example.com/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.com/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?

Topic google-search Wordpress search

Category Web


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.com/?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.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.