OpenSearch, how to get Google Chrome to search your site.

Ever wonder how sites like battle.net support things like this in Google Chrome?

Well I did, so I did a little bit of digging. It turns out Google Chrome supports an open standard called Open Search. This format is relatively simple, and very easy to add to your own site. I just added it to some of our systems in under 5 minutes.


Adding OpenSearch to your site is incredibly simple, you just have to add a simple tag to your index HTML page, and add a simple XML file that it points to. The link tag looks like this:

<link rel="search" type="application/opensearchdescription+xml" href="http://my-site.com/opensearch.xml" title="MySite Search" />


The opensearch.xml file looks something like this:


<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
   <ShortName>My Site</ShortName>
   <Description>Search My Site</Description>
   <Url type="text/html" method="get" template="http://my-site.com/search?{searchTerms}"/>
   <Image height="16" width="16" type="image/vnd.microsoft.icon">
http://my-site.com/favicon.ico
   </Image>
   <moz:SearchForm>http://my-site/search</moz:SearchForm>
   <Url type="application/opensearchdescription+xml" rel="self" template="http://my-site.com/opensearch.xml"/>
</OpenSearchDescription>




And that's all, the first time someone visits your site, the link tag will be registered, and following attempts to type in that URL will provide them with the option to search (chrome), and it will nicely integrate with other search services as well.
1