Add Open Search to your webiste in five minutes

How to

You have a website.

Google makes a pretty good search engine.

Firefox 2 and Internet Explorer 7 both support OpenSearch as a way of customizing the browser’s search box.

And you can make all three work together in five minutes. No programming required.

Check this out:

Step 1: Save the template

Use the template below to create a file on your web server. I called mine “opensearchdescription.xml” and saved it on static.unto.net.

<?xml version="1.0" encoding="UTF-8"?> <OpenSearchDescription xmlns="/-/spec/opensearch/1.1/"> <ShortName>[Name of the site]</ShortName> <Description>Use Google to search [Name of site]</Description> <Tags>[Name of site]</Tags> <Url type="text/html" template="/search?q=site:[Site host] {searchTerms}"/> </OpenSearchDescription> 

Download the template here, save it to your server, and move on to step 2.

Step 2: Edit the template

Replace [Name of site] and [Site host] in the template above with the appropriate values for your site. Remember that [Name of site] must be 16 or fewer characters of plain text.

For example:

<?xml version="1.0" encoding="UTF-8"?> <OpenSearchDescription xmlns="/-/spec/opensearch/1.1/"> <ShortName>Unto.net</ShortName> <Description>Use Google to search Unto.net</Description> <Tags>unto dewitt clinton</Tags> <Url type="text/html" template="/search?q=site:unto.net {searchTerms}"/> </OpenSearchDescription> 

See the live Unto.net description file here.

Verify that you can load the edited template in your web browser, and move on to step 3.

Step 3: Add the autodiscovery link

Tell browers that visit your site about the new search engine using an autodiscovery link.

You’ll want to do this on every page on your site, so it is best to edit whatever template generates the header.

Edit the header of the pages on your website to include the following line between the <head></head> tags:

<link rel="search" href="[URL of the file you just created]" type="application/opensearchdescription+xml" title="[Site name]" /> 

For example, on blog.unto.net pages this line appears as:

<link rel="search" href="http://static.unto.net/opensearchdescription.xml" type="application/opensearchdescription+xml" title="Unto.net" /> 

(View source to see it live.)

Step 4: See it in action

Hit refresh in your web browser.

If it works, the search box in the upper right of either Firefox or IE should light up to indicate that a custom search engine was discovered.

Click on the drop down and select your new customized OpenSearch engine.

Search away!       

 

Credits: http://blog.unto.net/add-opensearch-to-your-site-in-five-minutes.html

Leave a Reply