Creating a Custom Search Engine (CSE) / Create a Search Box for Your Department

Method A:  To create a search that will display the results on the same page, use a Custom Search Engine (CSE).

There are many options for a CSE. These instructions will get you started with a basic CSE.

  1. Login to with a gmail account
  2. Click on "New Search Engine"
  3. Fill out the form
    1. Enter a site URL to search.
    2. Enter a name for this search engine.
  4. Click on the "CREATE" button.

To display the search form on your page:

  1. Click on "Look and feel".
  2. Select a template.
  3. Click on the "Save & Get Code" button.
  4. On the resulting page, click in the grey text box. The code will now be highlighted.
  5. Copy the code.
  6. Paste the code into your page.

Method B:  To create a search that will display the results on a new page with the UH template, use Google's University Search.

Google has updated their CSE code. Please see for more information.

If you'd like to include a search box that will only search within your department's pages, you might try including the form below. It uses Google's search engine, but limits the results to only matches within your department's directory or site. If you set this up and get no results, please contact us.

Copy the below text to your page and replace "its" in the placeholder and hq input tag to the directory you want to search.

$q = '';
if (isset($_SESSION['q'])) {
        $q = $_SESSION['q'];

$hq = '';
if (isset($_SESSION['hq'])) {
        $hq = $_SESSION['hq'];

if (isset($_REQUEST['q'])) {
        $_SESSION['q'] = $_REQUEST['q'];
        $_SESSION['hq'] = $_REQUEST['hq'];
        header('Location: ?q=' . $_REQUEST['q'] . '%20' . $_REQUEST['hq']);
} // END check if q parameter passed
// IMPORTANT: all of the above code must be before anything else. 
// Template or page content goes below
<form action="">
            <input name="q" type="text" size="40" value="<?php echo $q; ?>" placeholder="Search /its" />
            <input name="hq" type="hidden" value="inurl:its" />
            <input type="submit" name="sa" value="Search" />

        (function() {
                var cx = '008945998903415758105:4nrwh9-26ni';
                var gcse = document.createElement('script');
                gcse.type = 'text/javascript';
                gcse.async = true;
                gcse.src = '' + cx;
                var s = document.getElementsByTagName('script')[0];
                s.parentNode.insertBefore(gcse, s);



Please rate the quality of this answer: Poor Fair Okay Good Excellent
Not the answer you were looking for? Try different keyword combinations and if you still can’t find your answer, please contact us.
Article ID: 711
Created: Wed, 14 Feb 2007 8:50am
Modified: Tue, 02 May 2017 11:25am