Step 29: Making everything searchable
Every website needs a site search. Period.
Rules for a good site search:
- Put the search box on every page, preferably "above the fold" (visible without scrolling).
- Search everything by default. If you have an option to search entries, comments, or both, make "both" the default.
- Don't clutter your search box with advanced options, like boolean logic, case sensitivity, or regular expressions.
- Choose defaults that mimic Google's behavior (match all words, don't match partial words, don't match case, don't use regular expressions) and make all the options visible on a separate "advanced search" page.
- Give your search box a proper label and an access key. I recommend accesskey="4" .
(Note: On step 15, I gave an example of how to assign an access key to your search form, and I got it wrong. For maximum cross-browser compatibility, you need to define the accesskey on the <label> , not on the <input> . See the examples below for the correct syntax.)
Jackie, Michael, Bill, Lillian, Marcus, and pretty much everyone else in the world benefit from a well-implemented site search. Especially on a weblog or news-oriented site, where content is primarily organized chronologically, it's very frustrating to try to find a specific post that's scrolled off the main page. Very few people know about the "site:domainname.com" syntax on Google (to restrict search results to a particular domain), and Google only reindexes once a month anyway. Provide your own site search.
- Google Custom Search Engine
- Improving accessibility with accesskey in HTML forms and links. Near the end, it explains why to use "4" as the accesskey for your site search.
- Is Navigation Useful?
Users often rely on search as their main hunting strategy.
- Search Usability. Five years old and still incredibly relevant.
- URL HOWTO. PHP.net has the most amazing site search I've ever seen. Beyond the standard search box, they use custom 404 ErrorDocuments (which would usually just throw a "page not found" error) to intelligently search the site based on the URL. So you can type an address like php.net/phpinfo into your browser's location bar, and php.net will redirect you to the reference page on the phpinfo function.