Adding Google search to your site

Written by:telekinetic
Published by:Nightscript
Published on:2005-06-05 16:56:47

A short and simple hack which will allow people to search your site using Google. This will only work if your site is indexed by google.

This article shows you how to add a simple Google search button which will let others search your site. Your site needs to be indexed by google for this to work.

All you need to do is add this code where you want the search form to be.

<form method="GET" action="">
    <input type="text" name="query" value="" size="20">
    <input type="hidden" name="as_sitesearch" value="">
    <input type="submit" value="Google my site">

Replace the hidden value "" with the name of your website where you plan on running the search.
This form will send the user's query to Google along with the name of your site. So if you typed a query like "osix", the query which will be "osix". Obviously you can use this method to search something in one particular site by directly typing the query at

The disadvantages of using this method are

  • You need to be listed in Google's search index
  • If you make some changes to a page those changes will take time to get updated in the google index and thus may not show up in the search results.
  • Google at some point of time may choose not to index your site.

Hope this was of some use.

This is an article from - view the original at: