How to let Google detect a site search engine?
Asked Answered
A

2

25

Google Chrome has a feature where you can hit tab to search a site. Chrome then navigates to the site's own search engine and runs the inputted query. The Chrome documentation indicates that this is only available if Google has detected a search engine on the site you are trying to search.

This indeed seams to be the case, because writing stackoverflow.com<Tab>test<Enter> makes Chrome navigate here while facebook.com<Tab>test<Enter> does nothing because the tab-key tabbes out of the address line.

What I'm wondering is then how to indicate to Google that my site has a search engine and how Google needs to format a query in order to redirect a Chrome user correctly to my site when the tab-search feature is utilised. Is it a Meta tag? Is it in robots.txt?

Amandie answered 29/12, 2012 at 14:25 Comment(1)
For anyone who needs the specification of OpenSearch mentioned in @Andreas's answer, OpenSearch. Also here's mozilla's description file. Other links: Official website TutorialPhylis
A
27

After a little digging I found this page that describes this. Also you can read in Stackoverflow's source code and find this line of code:

<link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml">

What it does is indicate to Google that the description for how to use your search engine in the file /opensearch.xml which contains this:

<?xml version="1.0" encoding="UTF-8" ?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
  <ShortName>Stack Overflow</ShortName>
  <Description>Search Stack Overflow: Q&amp;A for professional and enthusiast programmers</Description>
  <InputEncoding>UTF-8</InputEncoding>
  <Image width="16" height="16" type="image/x-icon">http://sstatic.net/stackoverflow/img/favicon.ico</Image>
  <Url type="text/html" method="get" template="http://stackoverflow.com/search?q={searchTerms}"></Url>
</OpenSearchDescription>
Amandie answered 29/12, 2012 at 14:25 Comment(2)
I can't see either rel="search" or any mention of "opensource" in the source for either the front page of auctions.yahoo.co.jp, or for any page I get back as a search result, so there must be more to this story. Maybe because 7 years have passed between this answer and today.Norris
@Norris Indeed, there is no trace of rel="search" in the yahoo (yahoo.com) website. Because of that (firefox) can't detect that this website supports site-search. OpenSearch is for browsers to detect search engines, not implement them!Odel
I
4

When I implemented a search function for my online Klingon dictionary, I found that I didn't need an OpenSearch description for Chrome to autodetect it as a search engine.

NOTE: While this is a simpler method, it does not allow for advanced features like specifying a search template, a custom favicon (Chrome automatically uses the favicon of the site) etc. It also might not work for other browsers than Chrome.

I started off with the instructions here Search Engine Autodiscovery: Google Chrome Autodiscovery, which say:

Interestingly the auto discovery only works if the search engine is at the homepage. You have to have either an input field of the type search or of the type text with the name s:

<form>
  <input type="search" name="s" />
</form>

or

<form>
  <input type="text" name="s" />
</form>

I got Chrome to autodetect the search engine on my website klingonska.org without using an OpenSearch description.

However I deviated from the above description, as I found I didn't need have to have field called s nor use type="search". My final <form> look something like this (in reduced form).

<form method=get action="dict/">
  <input name=q placeholder="Search dictionary…">
  <button type=submit>Search</button>
</form>

The cruicial factors seemed to be that the form was located on the root page http://<domain>/ page (not a subpage like http://<domain>/<dir>/<something>.html). And, IIRC, that the search form contain only a single field.

Iron answered 13/1, 2019 at 21:16 Comment(2)
It seems to work with a parameter named "q" too (like Google does).Filterable
@LewisKelsey I see no reason that it wouldn't, but haven't tried it. If you can, please try it and then add it to the answer above. :)Iron

© 2022 - 2024 — McMap. All rights reserved.