How to Add Simple Google Site Search to Any Website

Built-in search engines of WordPress, Drupal and other content management systems are good, but not as good as Google. Here is a simple way to create a Google search form that will return results only from your site:

<form name="google-search" method="get" action="http://www.google.com/search">
	<input type="hidden" name="sitesearch" value="http://yourdomain.com/" />
	<input name="q" type="text" />
	<input type="submit" name="sa" value="Google" />
</form>

which will look like this:

This form does redirect your visitors to Google, but the results returned are only from your site, so there is nothing to worry about. And with Googling indexing blogs almost instantly, there are actually very little drawbacks from using this approach for site search.

3 Comments

  1. This is a pretty bad approach – Google allows for results to be integrated inside the site itself, thus providing a much better user experience.

    • kaspars says:

      In what way is this bad, Artem? Google’s CSE comes at $100/year minimum. Other options include using some nasty iframes and javascript. At the same time I agree that users could be confused by being redirected to Google. However, I don’t think that affects their ability to find what they were looking for.

  2. David Chin says:

    Thanks for this simple but effective solution. It’s a great alternative for those who don’t want to deal with the Google CSE version.

Leave a Reply to David Chin Cancel reply