Implementing Google Custom Search on WordPress
Google Custom Search can dramatically improve the search results for your WordPress blog or any other site. WordPress is a great blogging platform, no doubt about it. But the built-in search feature is terrible. As I've searched for keywords from past posts to respond to reader questions, I would continually come up empty-handed.
As a solution, I incorporated Google Custom Search, which is a free service that allows you to embed a Google search box and results (limited to just your site and any other sites you specify) on your site.
Try it out by searching for something using the search at the top of my sidebar. Not only are the search results more accurate, when you start running a few searches, you begin to see how your site appears to people who search for you in Google.
One thing I immediately realized was that a lot of my archives pages were appearing in posts. The search results would begin with my blog title followed by the word archives followed by the post title (which was then truncated due to space constraints). It's important to have just one version of your post in Google's search results, so that your other posts aren't competing against each other. (For more on this, research canonical URLs in WordPress.) I also wanted the search engine result to begin with the post title.
To fix the display of the results, I implemented the All in One SEO plugin and configured the plugin's settings so that only the single post would appear in the search results, not the archives. I then created a sitemap (using the Daigon Design sitemap generator as well as the Google XML Sitemap plugin), generated both sitemaps, and linked to the Daigon Design sitemap in one of my latest posts so that Google would reindex all the posts on my site.
Implementing Google Custom Search
Implementing Google Custom Search in a WordPress site can be a little tricky. The Google Custom Search WordPress plugin didn't work for me, so I just copied the Google code manually.
Google gives you two pieces of code: code for a search box and code for the search results. Choose the iframe option before generating the code. For the search results page, type the name search. Insert the search box code in your sidebar somewhere. Then create a page called Search that uses a page template with the search results code. Also copy the search results code into the search.php page of your theme.
As you accrue more and more posts in your blog, you need an fast and accurate way to retrieve posts based on vaguely remembered keywords. WordPress's built-in search won't always find what you're looking for. If users are savvy, they can use site:yourdomain.com keywords to search your site at Google.com. But embedding the search form directly on your site is much more user-intuitive.
I'd Rather Be Writing Newsletter
Get new posts delivered straight to your inbox.
About Tom Johnson
I'm a technical writer based in the California San Francisco Bay area. In this blog, I write about topics related to technical communication — Swagger, agile, trends, learning, plain language, quick reference guides, tech comm careers, academics, and more. I'm interested in , API documentation, visual communication, information architecture and findability, and more. If you're a technical writer of any kind (progressional, transitioning, student), be sure to subscribe to email updates using the form above. You can learn more about me here. You can also contact me with questions.