As a serious web addict, I'm frequently frustrated by sites that don't offer a way to search their content. Navigating through a maze of different sections, trying to find that one piece of information I'm after feels like a waste of time. Often I'm forced to leave the site, bring up Yahoo! Web Search, and use its site: meta keyword. The site: shortcut lets you specify that the search results should be limited to a single domain.
For example, if you browse to mountaindew.com, you're immediately blasted with metal music and an extreme Flash animation showing various extreme sports. But all I'm after is the number of calories in a can of soda, and there's not a search form in sight. I could try clicking on a few of the menu items, but I'd probably find more images of skateboarding than useful information. So I surf over to Yahoo! and type:
In a few seconds, I have a specific link deep within the mountaindew.com site that has the information I'm after, as shown in .
Figure 1. Search results for "calories" limited to mountaindew.com
PepsiCo, Inc. (the owners and operators of http://www.mountaindew.com) probably has the budget and team of developers to build its own search engine for the site if it wanted to. But many individuals and small businesses don't have that luxury. Since Yahoo! is probably already indexing any pages you have on the Web, you could easily give your readers a shortcut to searching your site with a custom Yahoo! search form.
Running the Hack
All you need to do to customize the code is insert your domain name in the second radio input tag. You can add this HTML to any existing web page to provide your readers with a way to search your site. In a browser, the result looks like .
Figure 2. Custom Yahoo! search form
The "Search this site" option will be selected by default, but users could also search the entire Web from the form. While this won't make your site as extreme as http://www.mountaindew.com, at least your visitors will be able to find exactly what they're after.
In addition to the site: meta keyword, some tweaks to a standard Yahoo! Web Search URL will also limit results to a single domain. Here's a search URL that will return the same results as the previous example:
As you can see, the p querystring variable holds the search query and the vs variable indicates the domain to limit the search results to. Armed with this information, here's a bit of HTML that will build the proper URL:
<input type="text" name="p" size="34" />
<input type="submit" value="Search" />
<input type="radio" name="vs" value="" id="websearch" />
<label for="websearch">Search the web</label>
<input type="radio" name="vs" id="sitesearch"
value="insert your domain" checked="checked" />
<label for="sitesearch">Search this site</label>