rss

Custom Firefox Search Engine

March 18, 2009

Learn how to easily add a Firefox search engine add-on for your web site. Even add a custom icon.

The book publisher O'Reilly has a great article on how to write your own Firefox search engine add-on. There are a lot of details there that you don't need to know if your site doesn't have its own search or you just want to rely on Google to provide the results, though. In this post I'll explain how to quickly create a customized copy of the Google search engine add-on that comes with Firefox so that it returns results limited to one particular site of your choosing. I'll show how to do it manually and then I give you a link to a page where you can fill in some information and have the file generated for you - complete with custom icon. Then I'll explain how to install the new search engine.

Option 1: Manually customize the default Google search

Download the sample file. Change the text in the title, description and search parameters areas to values appropriate to your site. To be more specific, change the lines:

<ShortName>YourSite</ShortName>
<Description>YourSite Search</Description>
<Param name="q" value="site%3Ayoursite.com+{searchTerms}"/>

to:

<ShortName>MySite</ShortName>
<Description>MySite Search</Description>
<Param name="q" value="site%3Amysite.com+{searchTerms}"/>

Give the file a name fitting for your site and with the .xml the file extension. For example, name the file mysite.xml or something similar.

Option 2: Fill in some info and have the file generated for you

I have written a script that you can use to generate the correct search engine add-on file for you. All you have to do is fill in some fields and click 'Create'. You can even provide an image file to have a custom icon created for you.

Installing the search engine add-on

The following instructions assume that your copy of Firefox is in a standard location. If it's not you will need figure out where it is installed and updated the instructions appropriately.

First, copy the XML file you created above to your Firefox searchplugins directory:

On Windows: C:\Program Files\Mozilla Firefox\searchplugins
On Mac OS X: /Applications/Firefox.app/Contents/MacOS/searchplugins

Second, restart Firefox. Your new custom search engine add-on should appear in the search engine list next to the search field.