Google Site Search

After frustrations with the K2/WordPress search on my site, I've switched to Google custom search.  I'd never really used the built-in stuff, but when I was setting up my project pages, I did a bunch of searching, and it just didn't seem to work very smoothly.  In particular, you have to manually URL-escape your search string (e.g. replace spaces with pluses) for it to work right.

The Google interface is devoid of such issues, of course, and has the added benefit of searching my full domain, not just my blog posts.  I also included my public Subversion repositories in the search scope, though I'm not sure I'm going to leave that.  The high-churn nature of source code repositories makes for often-outdated results.

The integration was a snap: drop the form code in a Text Widget on the sidebar, and drop the results code in the body of a new Search Results page and I was done.  There were three minor gotchas I had to resolve:

  1. The form didn't repopulate with the current search query on the results page.  That was easily addressed with a little JavaScript in the result page body.
  2. The results page IFRAME was too wide for the site layout.  Again, easily addressed with a little CSS in the result page body.
  3. WordPress lists all top-level pages across the top, and I didn't want the Search Results page showing up there, since clicking it doesn't make sense.  Addressed with a little CSS in the search form widget.

One response to “Google Site Search”

  1. rob

    Wow, that works pretty well.