Incorporating "Search This Site" Functionality on a Web Site

With the addition of some CSS and javascript, you can enable users to search your website and find your Web pages/documents.

Here is a sample form using the OIT's website as an example:

<style>.gsc-tabsArea {display:none;}</style>
<script>
  (function() {
    var cx = '013791975455744583637:d-5gpo8xk5e';
    var gcse = document.createElement('script');
    gcse.type = 'text/javascript';
    gcse.async = true;
    gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(gcse, s);
  })();
</script>
<gcse:search as_sitesearch="oit.nd.edu"></gcse:search>

To make this form work for you, change "oit.nd.edu" to the url of your website. You can specify subdirectories.

When naming the website:

  • Do not include "http://"
  • Do not include trailing slashes (/)
  • Do not specify specific file names
     

Examples of valid specifications:

  • president.nd.edu
  • vocation.nd.edu
  • www.nd.edu/~biology
  • nd.edu/~gender
  • www.business.nd.edu/IA
     

Examples of invalid specifications:

  • http://www.nd.edu/~forestry (includes "http://")
  • www.nd.edu/vetschool/ (includes a trailing slash)
  • nd.edu/textiles/conference.pdf (points to a specific file)


For more information about the campus-wide search engine, such as how it works, what it indexes, and how you can allow or disallow it to index your site, see the About The Campus-Wide Search Engine page.