|
Whether
you're running a large site for a company or your
own corner of the Web, a search engine will bolster its usefulness. Dave
Carter explains.
With
billions of Web pages and mountains of data stored in online
repositories, it's vital to include a search facility on all but the
most basic
of sites. Although Google offers a site search feature, building
your
own simple search engine is a more rewarding option.
Google's
site search allows you to restrict searches to a singledomain,
in effect providing a search engine for your site. Simply add
"site:<url>"
to
either the beginning or end of your search query.
|
Google
it: Google
can be used to
search most sites on the Web, but it's
a lot more professional and fun
to build your own search engine.
|
For instance, the
query for a
search of "Business" on www.southwestcomputing.biz
would
look like this:
business
site:SouthWestComputing.biz
What is needed now is a form on your
own page that
allows users to search your site without having to
head over to Google. A simple HTML form will do the trick. Here is an
example which keeps search results limited to www.southwestcomputing.biz:
<form
action="http://www.google.com/search"
method='GET">
Search
SouthWestComputing:
<input
type="hidden"
name="q" value="site:SouthWestComputing.biz">
<input
name="q"
size="20">
<input
type="submit"
name="submit" value="Search">
</form>
The
"site:<url>"option
is passed to Google
as a hidden input value.
This ensures the search is always on the selected domain rather than
the entire Internet, so the user doesn't
have to enter the option every time. Google requires no other special
values,
just the query itself.
Note: Be aware that to search your
whole site Google needs to
have spidered it ALL. This can sometimes take quite a while so make
sure every page has been checked and is in the Google database before
using this approach.
|