Sidebar¶
This theme has sidebar that is located on the left side of the screen on PC and can be revealed by pressing Menu button on Mobile.
Sidebar is used for displaying Sphinx’s toctree. You
can customize the toctree-related settings or add
your own content to the sidebar.
Adding custom content¶
You can override the layout.html template, specifically
the sidebar block. The content will be displayed on
both PC and Mobile views. Don’t forget to call super to
avoid removing the Table of Contents.
{% extends "!layout.html" %}
{% block sidebar %}
{{ super() }}
<div id="ethical_ads">
<!-- ... -->
</div>
{% endblock %}
Tweaking Table of Contents¶
To pick the settings for Table of Contents rendered in the sidebar, you can use the following options:
html_theme_options = {
...
"navigation_include_hidden": True,
"navigation_titles_only": True,
"navigation_collapse": True,
"navigation_depth": 3
}
The values displayed above are the default.
Those options essentially mirror the toctree
directive options includehidden, titlesonly,
collapse and depth. To make sure that your page
will appear on the sidebar’s table of contents, ensure
that it is either referenced in any of the toctrees
on your root page (usually /index.md or /index.rst)
or on toctree of another page that is directly or
indirectly included.
See also
The concept of Table of Contents and related config options is described in the Sphinx’s own documentation, in this paragraph of Directives Reference.
CSS Variables¶
The following CSS variables influence the look and feel of Sidebar’s Table of Contents:
Sidebar | |||
|---|---|---|---|
Variable | Default value | Description | |
Light mode | Dark mode | ||
|
|
| Background color of the revealed sidebar on mobile layout. |
Header (collapsed) | |||
Variable | Default value | Description | |
Light mode | Dark mode | ||
|
| Background image of header/button that is used when TOC section is inactive. Match it with the border. | |
|
| Color used for header/button of inactive TOC section. | |
|
| CSS filter applied to the header/button of inactive TOC section. | |
|
| Color of text displayed on header/button of inactive TOC section. | |
|
| Border image configuration for header/button of inactive TOC section. Match this with background. See also Documentation for Border Images and the border-image Generator. | |
|
| ||
|
| ||
Header (open) | |||
Variable | Default value | Description | |
Light mode | Dark mode | ||
|
| Text of local TOC’s header. | |
|
| Background image of header/button that is used when TOC section is active. Match it with the border. | |
|
| Color used for header/button of active TOC section. | |
|
| Border image resource used for header/button of inactive TOC section. Match this with background. Note To maintain geometry of the header/button, borders for both active and inactive TOC sections have same configuration, except for the image. To set those, refer to variables listed in Header (collapsed) section. | |
Body (open) | |||
Variable | Default value | Description | |
Light mode | Dark mode | ||
|
| Background image used for body of active TOC section. | |
|
| Border image configuration for header/button of active TOC section. Match this with background. See also Documentation for Border Images and the border-image Generator. | |
|
| ||
|
| ||
|
| Color of text in the body of an open TOC section. | |
|
| Color of link to the currently open page/chapter in the body of an open TOC section. | |