Wednesday, 27 June 2007

Create a custom Google search engine for your blog

Visitors to your blog will often be looking for specific information, which all too often is lost amidst the archives and categories or labels in which you have organised your posts. The best way to ensure readers can find the posts they are interested in is to include a search function in your blog.

Most blogging platforms already have some sort of search function installed. Blogger blogs, for example, have a "search this blog" box in the navbar. However, the best search method I have found is to create a custom search engine for your blog using Google's free Custom Search Engine service.

This custom search engine has many advantages. You can:

  • Include a search box in your blog

  • Customise the results pages to match your blog style

  • Include only your blog, selected websites/blogs, or even the whole world wide web!

  • Incorporate Adsense in the search results

  • Check if all your posts and blog pages are being indexed

Also, your search engine is hosted by Google and has it's own page which others can use too.

Here's how to create your own custom search engine and add search functionality to your blog:

  1. If you don't already have one, create a free Google account here.

  2. Visit this page and choose to create your custom search engine.

  3. Give your search engine a name and description. This may be your blog's name, or you could choose something different.

  4. Choose some keywords which you would use to describe your blog. Make sure these are relevant to your content as they will be used to filter search results.

  5. Decide if you prefer the search engine to search only your blog, specified sites, the whole web with emphasis on your sites, or if you would like it to act like Google's own search engine. If you specify sites, include the full URL(s) in the box provided.

  6. You can only choose not to feature ads if you are a non-profit organisation. However, you can link your Adsense account to your search engine, so that you will earn money from the ads displayed.

  7. Agree to the terms of service and click "Next". Congratulations! You have created your custom search engine! You can try it out using the search function on this page to preview your results and they way they are displayed.

Now you will probably want to customise your search engine. Click on "My search engines" in the left sidebar, and choose "Control panel" next to your search engine's name. Next you'll see tabs for customisation options at the top of the page.

Adding the search box to your blog:

First, let's get the code you'll need to add a search box to your blog. Click on "Code" and select the branding style you prefer. I've chosen the "watermark" style which you can see in my right sidebar. The code will be generated for you in the box beneath, which you can then copy and paste into the layout of your blog where you would like it to be displayed.

If you find that the width of the search box is too large, you can easily adjust this. Find the following line in the search engine code:

<input name="q" type="text" size="40"/>

The value "40" refers to the number of characters which will be shown in the search box. Change this value to a smaller one to make sure the search box fits your layout better (mine is set to 30 characters to fit in the sidebar with a width of 240 pixels).

Changing the appearance of search results:

The appearance of search results can be customised by clicking on the "Look and feel" tab in the dashboard.

You can use your own banner to be displayed at the top. This must be no taller than 100px and should be hosted elsewhere. Input the full URL of your banner into the box provided. You can also choose for this banner to be a linked image to your site.

The colour schemes can be changed in a similar way to AdSense ads: simply input the hexadecimal codes of the colours you would like to be used for each setting. You could use the same colours as are in your blog. For assistance with hexadecimal colour codes, CeDesign has a great colour calculator you could try.

Linking search engine to your AdSense account

If you have a Google Adsense account, you can make money from the ads displayed in search pages. Simply click on the "Make Money" tab and input your Adsense account details to make the association. If visitors click on the ads from your search results, you will be paid in the same way as when ads are clicked on your blog!

Check that all your pages are being indexed!

One further use of your search engine is to check that all your blog posts and pages are being indexed. Search your own blog using keywords from different posts to ensure the correct results are being displayed. If you notice pages or posts aren't showing in search results, take a look at this tutorial for ideas of how you can help them be indexed faster.

Technorati Tags:

No comments:

Post a Comment