Set up search and versions¶
The theme draws a search button in the header and a search dialog on every page. The dialog lists pages, the sections inside them and API names such as functions and classes, from the index Sphinx already writes.
Search a site¶
Press Ctrl+K, ⌘K or / anywhere on a page, or choose the search button in the header.
Type what you are looking for. Results appear as you type.
Use ↑ and ↓ to move through them and Enter to open one.
Enter with nothing chosen opens Sphinx’s full search page with the words typed. Esc closes the dialog.
Stop results as you type¶
Set
search_as_you_typetoFalse:html_theme_options = { "search_as_you_type": False, }
Typing in the dialog now lists nothing, and Enter opens the full search page with the words typed.
Turn search off¶
Set
disable_searchtoTrue:html_theme_options = { "disable_search": True, }
No page now carries the button or the dialog, and the shortcuts do nothing. Sphinx’s own search page is still built. Options lists the three options with their defaults.
Why search stays in the reader’s browser¶
Search reads the index Sphinx writes with the site, so it works on any static host. It sends nothing anywhere: the words a reader types never leave their browser.
Warn readers of an old version¶
Set
show_version_warning_bannertoTrue:html_theme_options = { "show_version_warning_banner": True, }
On any version other than the preferred one, a banner above the header now says which version the reader is on and links to the preferred one.
Check the file at build time¶
The build reads the file once at its end and warns, naming the address, when the file is missing,
unreadable, not JSON or not a list of entries with a version and a url. The build still
succeeds. To skip the check, for a file you publish after the build, set check_switcher to
False.