Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML: How to get sub-links and search box display upon google search [duplicate]

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?

like image 725
Henry Zhu Avatar asked May 25 '16 20:05

Henry Zhu


People also ask

How do I add sitelinks?

You can add sitelinks at the "account", "campaign", or "ad group" level. You specify the link text (what shows to people) and the URLs (the pages they click to). In some cases, Google might supplement your sitelinks with descriptions that you've provided about those pages.

How do I add a link to Google Search?

In order to do so, go to Google search and type 'site:Sitename.com' and in place of 'Sitename', users have to mention the name of their website. If the content is listed, you will be able to find it after you click on search.


1 Answers

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/


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

like image 143
AndrewL64 Avatar answered Sep 25 '22 19:09

AndrewL64