SEO - how to get a search bar at google?


(Frederik L) #1

Hey,

This is the content you see at google when you search at my site (I know you might not understand the text):

48

This is how it look if you e.g search at “Lægeforeningen”.

How to change the layout at google to e.g include a search bar for my site and nice layout then the “random” text at the moment?

I dont know anything about SEO :smiley: Are there anything I can do ?


(Vinoth Kannan) #2

For search box you may need to add some code inside <head> tag as suggested here Sitelinks Searchbox  |  Search  |  Google Developers. And I think site links need to be configured via Google Webmaster tools.


(Joffrey Jaffeux) #3

The URL of a search in discourse has the following format:

https://your.domain.tld/search?q=test

So I think if you added this to the body of a theme component (the only thing you have to change is your.domain.tld):

<script type="application/ld+json">
{
   "@context": "http://schema.org",
   "@type": "WebSite",
   "url": "https://your.domain.tld/",
   "potentialAction": {
     "@type": "SearchAction",
     "target": "https://your.domain.tld/search?q={search_term_string}",
     "query-input": "required name=search_term_string"
   }
}
</script>

It could eventually work, bear in mind, that in the end only google is deciding if this will show or not, so you could add this code and it would do nothing.


(Joffrey Jaffeux) #4

@sam we might want consider doing this by default what do you think ?


(Joffrey Jaffeux) #5

I think it’s in body, do you see somewhere it’s saying <head> ?


#6

this would be pretty badass if it was on by default…


(Vinoth Kannan) #7

Yes it can be placed in body. Pinterest also placed it in body only.


(Jeff Wong) #8

It definitely sounds like a pretty cool feature for public sites, but I’d just like to caution that it would look weird on private ones. My preference would be to have it off by default, or have the ability to turn it off for private sites.


(Frederik L) #9

Now I did try to to add that snippet.

We will see if google eat it and it will add a search bar

Any way thanks for the help!


(Sam Saffron) #10

I kind of like it, @codinghorror what do you think?


(Mittineague) #11

AFAICT, the sitelinks generally display in the SERPs when the search terms are more “general”.

For example a search for “Discourse meta” shows sitelinks. But a search for “discourse seo search bar google” will not have them under the link to this topic, nor under the same Discourse meta link after it that had them for the more general search.

Kind of like “give me the table of contents” vs “give me this page”


(Jeff Atwood) #12

I dunno we already have this

<link rel="search" type="application/opensearchdescription+xml" href="https://meta.discourse.org/opensearch.xml" title="Discourse Meta Search">

Are people really going to be searching for the name of the site? That seems like a rare edge condition to me, not something we want to add permanent markup for.


(Felix Freiberger) #13

Yes, people do this all the time. They do it because they don’t know what a URL is or how to create a bookmark – it’s simply their way to open any website.

This is somewhat sad, but surprisingly true :sadpanda: