Ad

HTML: How To Get Sub-links And Search Box Display Upon Google Search

- 1 answer

So if I google StackOverflow, I get the following result (with a search bar):

enter image description here

Is there a way to get this search box to display on my website using some HTML or Javascript code?

Ad

Answer

You need to add some Schema Code to your website's HTML like this:

<script type=”application/ld+json”>

{

“@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”

}

}

</script>

After adding the above Schema Code, you will have to submit your URL to Google via this link: https://developers.google.com/structured-data/testing-tool/https://developers.google.com/structured-data/testing-tool/


N.B. You will need to change the url and target links to your own domain.

Ad
source: stackoverflow.com
Ad