Add a search plugin to your site

I just added a search plugin to my site. Unless you use Firefox 3 and noticed the small blue highlight on the arrow, it’s fairly difficult to notice, but for those who - like me - make good use of that box, it’s a nice thing to have.

Let’s start with the easy bit: the addition to the header. In Wordpress, you simply go into “Design”, then the “Theme Editor” and pick “header.php”. Add a line in, on a blank line, somewhere between <head> and </head&gt:

<link rel="search" type="application/opensearchdescription+xml" title="Esotechnica” href=”http://www.esotechnica.co.uk/search.xml” />

Naturally, change the “Esotechnica” parts (highlighted) for your own site. I chose to put the plugin on /search.xml; Cuil (which is what I used as a template) used /static/plugin.xml. Change to suit, but for easy mode leave that as is.

Now we need to build the XML file. With one small exception, it’s quite easy. Here’s mine - change the highlighted bits again:

<?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>Esotechnica</ShortName>
<Description>Esotechnica Search</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image height=”16″ width=”16″>data:image/x-icon;base64,lots</Image>
<Url type=”text/html” method=”get” template=”http://www.esotechnica.co.uk/?s={searchTerms}” />
<moz:SearchForm>http://www.esotechnica.co.uk</moz:SearchForm>
</OpenSearchDescription>

Obviously, the “URL” term needs to be your search - just change the domain for wordpress, the rest will be fine. (You can, of course, use Google, even without a search of your own: just use http://www.google.com/search?q={searchTerms}&as_sitesearch=www.mysite.com.)

The base 64 of your icon - where I’ve put “lots” is hard to get hold of. If you don’t have a bookmark icon (usually called favicon.ico and located in the root of the site, then remove that whole line.

Otherwise, use a base64 program to encode it (use WinZip or WinRAR on Windows), open with Notepad (or vi on Unix), replace the “/” characters with “%2f”, change the “=” signs at the end with “%3d”, make it all a single line, copy it and use it to replace the “lots”.

Now upload the XML file as the name you gave earlier (/search.xml was what I used earlier) and then test it with Firefox. Go to your site - check for the highlight behind the down arrow in the search, drop it down and test. If all goes to plan it should be fine. If not, leave a comment here and I’ll try and help…

Tags: , , , ,



One Response to “Add a search plugin to your site”

  1. Simon Collis Says:

    PS, forgot to mention: it also works in IE 7 and 8 as well ;-)

Leave a Reply