Home
  • About
  • Contact
  • My Calendar
  • Presentations
  • WordPress Consulting
  • Advertising
  • Podcasts
  • Jobs

  • Implementing Google Custom Search on WordPress

    January 8th, 2010 | Posted in Web Design 7 Comments »

    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.

    Canonical Posts

    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.

    These icons link to social bookmarking sites where readers can share and discover new web pages.
    • del.icio.us
    • StumbleUpon
    • Facebook
    • LinkedIn
    • TwitThis

    Tags: , , , , ,

    7 Responses to “Implementing Google Custom Search on WordPress”

    1. [...] rest is here: Implementing Google Custom Search on WordPress | I'd Rather Be … var AdBrite_Title_Color = '006DAD'; var AdBrite_Text_Color = '000000'; var [...]

    2. CJ Spurr says:

      Thanks for the information. I have been tweaking my blog and looking for ways to make it better. I have heard that the WP search wasn’t all that, so I appreciate the review on a better option.

    3. Ivan Walsh says:

      Tom,

      If you want to monetize GCS, you can tell Google to search site 1, site 2 and site 3.

      Then, when someone goes to these sites, if a person clicks the links, you’ll make money from the Adsense fees.

      Many sites/blogs are structured so that the user is ‘encouraged’ to search, i.e. so they click on the results + generate fees to the webmaster.

      Ivan

    4. I think having this on your blog is very helpful for your users, rather than opening a new tab etc they can just search straight from your blog!

    5. Yash says:

      I did what you have written but couldn’t get through. Is there any css tweak too?

      • Tom Johnson says:

        You know, I tried a lot of different things to get it to work, and now I can’t remember what the magic tweak was. Basically, I believe that creating that page within WordPress’s pages (not just a file within the theme) was helpful.

    6. [...] on google.com resolves…), but there is a plugin you could try. If that doesn't work, Google found these posts on doing it yourself that look quite good. __________________ Pole Exercise – Pole [...]

    Leave a Reply

    « »