Friday, August 29, 2014

Adding opensearch to your site

What is Opensearch?


Opensearch allows you to specify how queries are formed when searching a website. You can read the documentation at opensearch.org


How to install it?


This is how I have achieve it on my site


First add a autodiscovery link to your site pages



<link rel="search" type="application/opensearchdescription+xml" title="Rabin's blog" href="/opensearch.xml"/>


Next you need to define the open search document which will be in /opensearch.xml file in your website



<?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>Rabin's Blog</ShortName>
<Description>Search Rabin's Blog: </Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">http://www.rabinshr.com/favicons/favicon-16x16.png</Image>
<Url type="text/html" method="get" template="http://blog.rabinshr.com/?s={searchTerms}&amp;submit=Search"></Url>
</OpenSearchDescription>

That’s it. The next time you have loaded the page, you should be able to search your site by pressing tab on Chrome.


Happy coding!






via Rabin's blog

No comments: