MIT Google: Add a Search Box to Your Site
On this page:
Add a Simple Search Box
Additional Search Box Parameters
Add a Simple Search Box
You can add a search box to your web site to help visitors find content on your site. You can restrict the search to a specified directory or search the entire MIT web site. The search box will look and behave like this:
- Insert the following HTML into your web page where you want the search box to appear (parameters in bold can be customized):
<form method="get" action="http://search.mit.edu/search">
<input type="text" name="q" size="32" maxlength="255" value=""/>
<input type="submit" name="btnG" value=" Search"/>
<input type="hidden" name="site" value="mit"/>
<input type="hidden" name="client" value="mit"/>
<input type="hidden" name="proxystylesheet" value="mit"/>
<input type="hidden" name="output" value="xml_no_dtd"/>
<input type="hidden" name="ie" value="UTF-8"/>
<input type="hidden" name="as_dt" value="i"/>
<input type="hidden" name="as_sitesearch" value="your_URL"/>
</form>An example of the your_URL format would be web.mit.edu/newsoffice or itinfo.mit.edu. Do not use a final slash on your URL.
- Customize the following parameters:
- name="q" size="32"
Sets the width (in number of characters) of the search box. You can change the size to suit your site's layout, but don't change the maxlength value. - name="btnG" value="Search"
The text that appears on the search button. (e.g., "Search News Office") - name="as_sitesearch" value="your_URL"
Searches will only include pages in the specified directory e.g., name="as_sitesearch" value="web.mit.edu/newsoffice"- You must specify the complete canonical name of the host server followed by the path of the directory.
E.g., web.mit.edu/newsoffice not web/newsoffice - If the ("/") character is at the end of the web directory path specified, then only files within that directory will be searched and files in sub-directories will not be considered.
E.g.,
web.mit.edu/newsoffice to include sub-directories
web.mit.edu/newsoffice/ to exclude sub-directories - as_sitesearch allows allows you to specify one directory (and all its sub-directories) as the domain to be searched—you cannot specify multiple disparate directories using this option. If your site spans multiple sites or directories, contact the MIT-Google Team.
- If you want the search feature on your site to search the entire MIT web site, delete the as_sitesearch and as_dt parameters.
- You must specify the complete canonical name of the host server followed by the path of the directory.
- name="proxystylesheet" value="mit"
This parameter specifies the stylesheet for the display of the search results. The default MIT search site style includes the standard MIT navigation header, and provides options for People and Offices Directory search. If you would prefer to design and use your own search results stylesheet, see Using Custom Stylesheets.
- name="q" size="32"
Additional Search Box Parameters
For further information on additional search parameters consult the Google Search Protocol Reference, which documents all the supported search parameters in detail.
Back To Top
