blandish
blandish

Reputation: 1385

Customizing Sphinx to avoid generating search box

Is there a simple way (i.e., without creating an entirely new theme) to customize Sphinx so that it generates HTML pages without the search box?

Upvotes: 13

Views: 3877

Answers (2)

blandish
blandish

Reputation: 1385

An alternative, which I discovered reading the alabaster theme documentation is to explicitly list which (if any sidebars) are desired in the conf.py file. For example, including this fragment in conf.py:

html_theme = 'alabaster'
html_sidebars = {
    '**': [
        'about.html',
        'navigation.html',
        'searchbox.html',
    ]
}

produces the searchbox; removing searchbox.html from that list and then building produces the same page but without the box. (More information can be found at the Sphinx documentation for the build-configuration file.)

Upvotes: 17

mzjn
mzjn

Reputation: 51002

You can do it by customizing (or should I say disabling) the searchbox template.

  1. In conf.py, add this line:

    templates_path = ["templates"]
    
  2. Create a folder called templates in your Sphinx project directory.

  3. In that folder, add an empty file called searchbox.html. This overrides the default template file (located in sphinx/themes/basic where Sphinx is installed).

Upvotes: 14

Related Questions