I just added simple search to this site for my blog posts with the following code:
<form action="http://google.com/search" method="get">
<input type="search" name="q" placeholder="Search" results="0" />
<input type="hidden" name="q" value="site:wiseheartdesign.com" />
This will create a working search input that looks like this:
The code above leverages a number of little known facts about HTML forms and Google:
q. This will produce a query string that looks like this:
q=test&q=.... Note the presence of two
qparameters. Google combines both parameters to create the complete search query.
site:wiseheartdesign.comwhich appends this to the end of the normal search string. Google uses this limit a search to a given website.
http://google.com/search. The “action” attribute can be a full URL to another site. It doesn’t have to refer to a URL on your own site.
© 2013 John W. Long