Configuration#

If you want to use the insipid theme, only a single setting is required in your conf.py:

html_theme = 'insipid'

However, you may also want to change the default symbol for section title links from the default ¶ to something more meaningful like # or § or maybe 🔗:

html_permalinks_icon = '#'

If the sources of your documentation are hosted publicly, you should set:

html_copy_source = False

… and follow the instructions at html_show_sourcelink to get automatic source links in the page footer.

Theme Settings#

The insipid theme has many configuration parameters which can be specified with html_theme_options in your conf.py, for example like this:

Listing 1 A simple conf.py#
html_theme = 'insipid'
html_theme_options = {
    'body_centered': False,
    'breadcrumbs': True,
}

You can also have a look at the example below.

All available theme options are listed in the following sections.

insipid Settings#

The following settings are provided by the insipid theme. See below for default values.

body_centered#

Set to False if you want the body text to be left-aligned.

If body_max_width is None, this has no effect.

breadcrumbs#

Set to True to show breadcrumb navigation (including a “home” button) at the top of each page (via the page.html template).

initial_sidebar_visibility_threshold#

The visibility of the sidebar depends on the setting from the previous visit, which is stored in the browser’s localStorage. If no information is available (i.e., on the first visit), the sidebar is hidden, except if the browser window is wider than the given threshold (in pixels or any CSS unit). If None is given, or if JavaScript is disabled in the browser, the sidebar is initially hidden, regardless of screen width.

left_buttons#

List of templates to show on the left side of the title bar.

You can use one of the built-in templates (ending with -button.html):

search-button.html

A button to show/hide the search field.

Note

This is only shown if html_sidebars does not contain 'searchbox.html' or 'searchfield.html'.

fullscreen-button.html

A button to switch to fullscreen mode (and back again).

Note

This will only be shown if fullscreen mode is available.

repo-button.html

A Bitbucket/Gitlab/Github logo linking to the associated repository.

For this to work, you’ll have to provide some information in your conf.py via html_context:

html_context = {
    'display_gitlab': True,
    'gitlab_user': 'myuser',
    'gitlab_repo': 'myrepo',
}

Replace gitlab with bitbucket or github if the repository containing your source files is hosted on Bitbucket or Github, respectively.

If you use a different hosting platform, you can override this template entirely.

pdf-button.html

A link to the PDF version of your docs.

You’ll have to make sure that a PDF version is built and uploaded and you’ll have to provide the URL to that PDF file in your conf.py via html_context:

html_context = {
    'downloads': [
        ('pdf', 'https://example.org/my-docs.pdf'),
    ],
}

You can also create your own template file(s) located in your templates_path. It’s best to use <a> or <button type="button"> elements. You can include other templates, most notably icons.

For example, a “home” button could be made by creating a file named _templates/home-button.html (relative to your conf.py) with this content:

<a href="{{ pathto('index') }}" title="{{ docstitle|e }}">
  {% include 'icons/home.svg' %}
</a>

… and adding the file name to html_theme_options like this:

html_theme_options = {
    'left_buttons': [
        'home-button.html',
    ],
}
templates_path = ['_templates']

For help creating your own templates, see sphinx:templating.

right_buttons#

List of templates to show on the right side of the title bar.

See also

left_buttons

rightsidebar#

Set to True if you want to move the sidebar from the left to the right.

show_insipid#

Set to False to hide the “Insipid Theme” link in the footer.

sidebar_overlay_width#

When the browser window is narrower than this value (in pixels or any CSS unit) – e.g. on a small mobile device – the sidebar will (partially) cover the main text. Set to None to disable.

sidebar_transition#

Duration (and optional timing function) of the CSS transition effect for showing/hiding the sidebar.

strip_section_numbers#

Section numbers (if you use them at all) are by default removed from previous/next links and from the title bar. Set to False to show them.

topbar_transition#

Duration (and optional timing function) of the CSS transition effect for showing/hiding the title bar.

basic Settings#

The following settings are inherited from the basic theme (therefore, most Sphinx themes have them), but for some of the options, the default values have been changed.

body_max_width#

Maximal width of the main document text (in pixels or any CSS unit). Set it to None for unlimited width.

body_min_width#

Minimal width of the main document text (in pixels or any CSS unit).

globaltoc_collapse#

If True (the default), only the current section of the table of contents (TOC) in the sidebar is expanded. Set to False to expand everything.

globaltoc_includehidden#

If True, include sections from toctree directives with the :hidden: flag in the table of contents (TOC) in the sidebar. By default, hidden sections are not included.

navigation_with_keys#

If True, the left and right arrow keys can be used to turn pages.

Note

This is disabled by default in the basic theme (and therefore in most other themes as well), for reasons given in Sphinx PR #2064.

When using the insipid theme, however, this is enabled by default.

nosidebar#

Set to True to completely disable the sidebar.

sidebarwidth#

Width of the sidebar (in pixels or any CSS unit).

Note

Whenever the sidebar is resized, its new width is stored in the browser’s “local storage”. Therefore, a changed sidebarwidth might not be immediately visible.

Default Values#

For default values, see:

Listing 2 insipid/theme.conf#
 1[theme]
 2inherit = basic
 3stylesheet = insipid.css
 4sidebars = globaltoc.html, separator.html, indices.html
 5pygments_style = friendly
 6
 7[options]
 8rightsidebar = false
 9
10left_buttons = search-button.html
11right_buttons = fullscreen-button.html, repo-button.html
12
13body_centered = true
14breadcrumbs = false
15strip_section_numbers = true
16
17topbar_transition = 0.3s ease-out
18sidebar_transition = 0.3s ease-out
19
20show_insipid = true
21
22sidebar_overlay_width = 39rem
23
24initial_sidebar_visibility_threshold = 100rem
25
26# Inherited from "basic" theme, but different default values:
27body_min_width = unset
28body_max_width = 45rem
29navigation_with_keys = true
30sidebarwidth = 19rem

Sphinx Settings#

Sphinx has a lot of settings – read the docs! Here we only show a small selection of configuration values which are relevant for the insipid theme.

html_copy_source#

When sphinx:html_copy_source is True (which is the default), all source files are copied to the HTML output directory (into the _sources sub-directory). The string given by html_sourcelink_suffix is appended to each file name.

Note

This has to be set to False in order to show links to the source files on Bitbucket/Gitlab/Github, see html_show_sourcelink.

When sphinx:html_show_sourcelink is True (which is the default), a link to the source file of each page is shown in the footer.

Traditionally, those links point to copies of the source files (when html_copy_source has its default value True).

However, when html_copy_source is False, the insipid theme (via the show-source.html template) will show links to the appropriate version of the source files on Bitbucket/Gitlab/Github, if the following fields of html_context are specified in your conf.py:

html_context = {
    'display_gitlab': True,
    'gitlab_user': 'myuser',
    'gitlab_repo': 'myrepo',
    'conf_py_path': '/path/to/doc/',
    'commit': '123abc',
}

The example above shows settings for Gitlab. Replace gitlab with bitbucket or github if the repository containing your source files is hosted on Bitbucket or Github, respectively. If the source files are hosted on a different service, you can manually override the template show-source.html.

The commit value should contain the hash (or tag name) of the commit which was used to create the docs. See this project’s conf.py for an example for how to obtain the relevant hash automatically via Git.

html_sidebars#

The content of the sidebar consists of the html_logo (if specified), followed by the list of templates in sphinx:html_sidebars.

You can choose from templates provided by the basic theme, like globaltoc.html, localtoc.html, relations.html, searchbox.html, searchfield.html and sourcelink.html.

You can also select templates from the insipid theme: home.html, indices.html and separator.html.

Finally, you can create your own custom templates. It’s best to use <h3>, <h4> and <p class="caption"> elements for titles, as well as “normal” <p> and <ul> (containing <li> elements which themselves typically contain <a href="..."> links). To distinguish between internal and external links, you can use <a class="reference internal" ...> and <a class="reference external" ...>, respectively.

See also

Theme options rightsidebar and nosidebar

html_theme_options#

The value sphinx:html_theme_options contains all custom theme settings.

language#

When a supported sphinx:language is chosen, all UI strings will be translated accordingly.

Example#

You can look at the conf.py file of this very documentation:

Listing 3 conf.py of the insipid docs#
  1# Configuration file for Sphinx,
  2# see https://www.sphinx-doc.org/en/master/usage/configuration.html
  3
  4import os
  5
  6# -- Recommended settings -----------------------------------------------------
  7
  8html_theme = 'insipid'
  9
 10html_permalinks_icon = '#'
 11
 12# If False, source links to Bitbucket/Github/GitLab are shown (using html_context)
 13html_copy_source = False
 14
 15# Update this with your own repo information:
 16html_context = {
 17    'display_github': True,
 18    'github_user': 'mgeier',
 19    'github_repo': 'insipid-sphinx-theme',
 20    'conf_py_path': '/doc/',
 21    'READTHEDOCS': os.environ.get('READTHEDOCS', False),
 22    # The 'commit' field is overwritten below (with data from Git).
 23    # If you prefer, you can also get it from your build environment,
 24    # e.g. READTHEDOCS_GIT_COMMIT_HASH.
 25    'commit': '???',
 26}
 27
 28# -- Settings for source code -------------------------------------------------
 29
 30# Language used for syntax highlighting (default: 'python')
 31#highlight_language = 'none'
 32
 33# Style of syntax highlighting
 34#pygments_style = 'monokai'
 35
 36# -- Language settings --------------------------------------------------------
 37
 38#language = 'es'
 39
 40# Date format used in footer. Use empty string for (language-specific) default.
 41# 'sphinx_last_updated_by_git' extension provides modification dates per page.
 42#html_last_updated_fmt = '%Y-%m-%d %H:%M:%S %Z'
 43
 44# -- Theme configuration ------------------------------------------------------
 45
 46html_theme_options = {
 47    #'body_centered': False,
 48    #'body_max_width': None,
 49    #'breadcrumbs': True,
 50    #'enable_search_shortcuts': False,
 51    #'globaltoc_collapse': False,
 52    #'globaltoc_includehidden': True,
 53    #'initial_sidebar_visibility_threshold': None,
 54    #'left_buttons': [
 55    #],
 56    #'navigation_with_keys': False,
 57    #'nosidebar': True,
 58    #'right_buttons': [
 59    #    'search-button.html',
 60    #],
 61    #'rightsidebar': True,
 62    #'show_insipid': False,
 63    #'sidebar_overlay_width': None,
 64    #'sidebar_transition': '1s ease-out',
 65    #'sidebarwidth': '10rem',
 66    #'strip_section_numbers': False,
 67    #'topbar_transition': '1.5s ease-out',
 68}
 69
 70html_sidebars = {
 71   '**': [
 72       'github-badge.html',  # Custom template, see _templates/
 73       'home.html',
 74       'globaltoc.html',
 75       'separator.html',
 76       'indices.html',
 77   ],
 78   'showcase/different-sidebar': [
 79       'localtoc.html',
 80       'searchbox.html',
 81   ],
 82   'showcase/no-sidebar': [],
 83}
 84
 85html_static_path = ['_static']
 86templates_path = ['_templates']
 87
 88# -- Project information ------------------------------------------------------
 89
 90project = 'insipid-sphinx-theme'
 91#html_title = 'Insipid Sphinx Theme'
 92html_short_title = 'insipid'
 93#copyright = '<insert year and copyright holder>'
 94#version = '3.14'
 95#release = '3.14.dev2'
 96
 97html_logo = 'showcase/insipid.png'
 98html_favicon = '_static/favicon.svg'
 99
100# -- Page footer --------------------------------------------------------------
101
102html_show_copyright = False
103#html_show_sphinx = False
104#html_show_sourcelink = False
105
106# Only relevant when html_copy_source is True
107#html_sourcelink_suffix = ''
108
109# -- Miscellaneous settings ---------------------------------------------------
110
111# Numbered figures, tables and code-blocks
112numfig = True
113
114html_secnumber_suffix = '\N{FIGURE SPACE}'
115
116#html_compact_lists = False
117
118#smartquotes = False
119
120# Generate alphabetic index
121#html_use_index = False
122
123# Separate page per starting letter
124#html_split_index = True
125
126# Generate domain indices, e.g. Python module index
127#html_domain_indices = False
128
129# The default in Sphinx 4+ is 'inline'
130#html_codeblock_linenos_style = 'table'
131
132# -- Sphinx extensions --------------------------------------------------------
133
134extensions = [
135    'sphinx.ext.autodoc',
136    'sphinx.ext.autosummary',
137    'sphinx.ext.intersphinx',
138    'sphinx.ext.viewcode',
139    'sphinx_last_updated_by_git',
140]
141
142intersphinx_mapping = {
143    'sphinx': ('https://www.sphinx-doc.org/', None),
144}
145