sitelinks searchbox wrong output

#10866
  • Resolved Bastian Fießinger
    Rank Math free

    This is the official code from Google for the Implementation of a sitelinks searchbox

    <script type="application/ld+json">
    {
      "@context": "https://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"
      }
    }
    </script>

    Where search_term_string should be the attr name of the query input. So in WP it would normally be s.

    RankMaths Code produces this:

    <script type="application/ld+json">{
    	"@context": "https:\/\/schema.org"
    	, "@type": "WebSite"
    	, "@id": "https:\/\/www.domain.com\/#website"
    	, "url": "https:\/\/www.domain.com"
    	, "name": "Website Name"
    	, "potentialAction": {
    		"@type": "SearchAction"
    		, "target": "https:\/\/www.domain.com\/?s={search_term_string}"
    		, "query-input": "required name=search_term_string"
    	}
    }</script>
Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    I have just raised this issue with our dev team and we will be looking into this and get back to you in a short while.

    We appreciate your patience. Thank you.

    ​​​​​​​

    Hello,

    In the example provided by Google that you pasted here, the search_term_string is actually a placeholder, as described on this page: https://developers.google.com/search/docs/data-types/sitelinks-searchbox

    A placeholder string that is replaced by user’s search query when the user clicks the “Search” button in the search box.

    The part that needs to be changed to make it work on most WordPress sites is the ?q= because WordPress uses the s parameter for the search query.

    The code inserted by Rank Math is therefore correct.

    Hope that helps.

    ah thanks… sorry was a bit confused about an example which used the search_term_string as the real input name..

    Hi Bastian,

    Thanks for the follow up.

    I am glad that this information was useful 🙂

    Feel free to contact us should any other issues come up.

    Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)

The ticket ‘sitelinks searchbox wrong output’ is closed to new replies.