How to Create an Autodiscovery Blog Search for Web Browser
Filed in: Web Development, Weblog, WordPress — October 30th, 2006
Have you add LiewCF blog search to your web browser? Many readers are excited by the feature. I will show you how to create an auto discovery blog search for web browsers. WordPress used in this example.

Add LiewCF blog search to your web browser (FireFox 2 in this example)
The OpenSearch technology
We are using OpenSearch technology for the auto discovery blog search. OpenSearch is a collection of simple formats for the sharing of search results. Currently, both Internet Explorer 7 and Firefox 2 support this feature. Please refer to OpenSearch.org for technical documents.
Overview
It is easy to create an autodiscovery search for web browsers. We need to create a simple xml file and add a line of code into your web page's header. That's all. Read on for details.
Note: This tutorial is for WordPRess blog. You might need to modify the code to work with your blogging platform.
Creating OpenSearch XML file
Now, we create a XML file which would be read and added into user's web browsers.
- Create a new plain text file
- Paste the following lines of code into it:
XML:
-
<?xml version="1.0"?>
-
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
-
<ShortName>YOUR_BLOG_NAME</ShortName>
-
<Description>YOUR_BLOG_DESCRIPTION</Description>
-
<Url type="text/html" template="http://YOUR_BLOG/PATH/index.php?s={searchTerms}" />
-
<LongName>YOUR_BLOG_LONG_NAME</LongName>
-
</OpenSearchDescription>
-
- Replace these terms in the code with yours:
- YOUR_BLOG_NAME -- the name of your blog
- YOUR_BLOG_DESCRIPTION -- tell people about your blog
- YOUR_BLOG/PATH -- your blog path
- YOUR_BLOG_LONG_NAME -- a longer blog name
- Save the file as "myopensearch.xml"
- Upload "myopensearch.xml" to your WordPress blog root.
Blog search auto discovery
In order to make web browsers auto discover our blog search, we need to add a <link/> tag into page header.
- Open "header.php" of your WordPress theme.
- Find:
HTML:
-
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />[html]</li>
-
<li>Add the following line of code immediately after the above line:
-
[html]<link rel="search" title="LiewCF.com Tech Blog" href="http://www.liewcf.com/blog/liewcf-opensearch.xml" type="application/opensearchdescription+xml" />
-
- So, it will look like this:
HTML:
-
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
-
<link rel="search" title="YOUR_BLOG_NAME" href="http://YOUR_BLOG/PATH/myopensearch.xml" type="application/opensearchdescription+xml" />
-
- Save "header.php" and upload back to your WordPress theme folder.
You're done! Back to your blog and add the blog search to your web browser. ![]()
References: Heath Stewart's Blog and Mozilla Developer Center
Bonus: WordPress OpenSearch plugin -- add OpenSearch RSS feed functionality to a WordPress blog. (Does not include browser AutoDiscovery)
Comments Feed
TrackBack URL


October 30th, 2006 at 6:20 pm
Thanks for the tutorial Liew. Will be adding the blog search to my blog as well now
October 30th, 2006 at 6:34 pm
[...] Read the complete tutorial » [...]
January 15th, 2007 at 4:27 am
[...] I was going to writeup a full ‘How to’ on this but there’s already a great one over at LiewCF so why re-invent the wheel. Check out Liew’s great post! [...]
March 24th, 2007 at 3:28 am
Thanks so much for a great tutorial! I hate to ask a really dumb question, but for those of us who just follow you instructions because we have no idea what we’re doing…
When I save the file as myopensearch.xml with Note Pad, what encoding do I use? UTF-8, Unicode? Does it make a difference?
Thanks so much for helping to make Happiness more visible!
March 26th, 2007 at 10:57 am
@Michhele Moore: UTF-8 or Unicode doesn’t matter because the code is standard alphabet characters.
May 3rd, 2008 at 11:05 pm
[...] Note: I owe credit to LiewCF: How to Create an Autodiscovery Blog Search for Web Browser [...]