Using Google Custom Search

If you want to include Search functionality on your docs site, you need to set up a Google Custom Search, and then link it to your nbdev project. Here's all the steps you need to follow (replace anything in {} with the value your have in settings.ini:

  1. Go to Google Custom Search and click 'add'.
  2. In "Sites to search" type the URL of your docs site (e.g. {owner}{lib_name}), and in "Name of the search engine" type "{lib_name} docs". Then click "CREATE"
  3. Click "Control Panel"
  4. In the "Basics" tab, click "Copy to clipboard" in the "Search engine ID" row
  5. Paste that as the value for "google_search:" in docs/_config.yml in your project. (If you don't already have this file, run nbdev_build_lib to create it, once you've set up your settings.ini)
  6. Click "Advanced" (far-right tab), then "CSE Context", then "Download (XML)"
  7. Open the downloaded cse.xml file in a text editor, and delete everything from the line starting with <LookAndFeel onwards (including that line)
  8. Replace those lines with the contents of this file: search-template.txt, and save it
  9. In your browser, in the same "Advanced" tab you downloaded cse.xml from, click Upload XML file and upload the updated cse.xml file you just save.

Usage tips

  • To see what documents google is currently indexing at any particular URL, use the site: operator without any search term. e.g. "". You can use this to sense check what a search term ought to return as the result
  • If Google isn't indexing your docs site, you can ask it to do so by following these instructions.