My site search had been powered by DuckDuckGo over the last year, and this weblog had been using the WordPress search widget since I started self-hosting in April. Today I’ve changed both to Google Search, so as to deliver better search results to my visitors.
I still recommend DuckDuckGo for general use, and keep it as my web browser’s default. However, DDG has never been that great with small websites, and that’s problematic for a site search. DDG often fails to present hits from my PDF documents, and sometimes from HTML pages as well.
The standard WordPress search is much more limited – no spelling corrections, no comment search, and only chronological results. Google fixes that, and also searches three sources at once: the weblog is automatically covered as a subdomain of the website, and I’ve connected my Google+ account as well. This means you’ll get the most complete set of relevant results, no matter where you search from.
Google Search for WordPress
Adding basic Google Search to any website, including WordPress blogs, is extremely simple. Contrary to what you might think after scouring WordPress.org, you don’t need a plugin! Simply create a blank “Text” widget (the one that says “Arbitrary text or HTML”), then paste the following HTML code into the main text area:
<form method="get" action="https://www.google.com/search"> <input type="text" name="q" maxlength="255" placeholder="Google Site Search" value="" /> <input type="submit" value="Go" /> <input type="hidden" name="sitesearch" value="kynosarges.org" /> </form>
kynosarges.org with the URL of your own website. The snippet uses a
hidden input element to request site search instead of web search. Use
type="checkbox" to let the user choose. Another alternative is to present two
type="radio" elements, one with
value="[URL]" as above, the other with an empty
value="" for web search.
Caveat: Any search that relies on external crawlers rather than the local WordPress database will exhibit some delay between posting a new article and seeing it in search results – perhaps up to a few days, depending on your blog’s popularity. I don’t see that as a big problem since the newest articles are always prominently visible anyway.