Skip to main content
Ctrl+K
PyData Theme

PyData Theme

Site Navigation

  • User Guide
  • Contributor Guide
  • Examples
  • Changelog
  • PyData
  • NumFocus
  • Donate to NumFocus
  • PyData

Site Navigation

  • User Guide
  • Contributor Guide
  • Examples
  • Changelog
  • PyData
  • NumFocus
  • Donate to NumFocus
  • PyData

Section Navigation

Get started

  • Installation
  • Theme Structure and Layout

Navigation and links

  • Navigation depth and collapsing sidebars
  • Page Table of Contents
  • Header links
  • Source Buttons
  • Sphinx indices

User Interface

  • Announcement banners
  • Version switcher dropdowns
  • Search bar / search button
  • Keyboard shortcuts
  • Internationalization

Content and features

  • Theme-specific elements
  • Blogs with ABlog
  • Sphinx Design Components
  • Extending the theme

Theming and Style

  • Branding and logo
  • Theme variables and CSS
  • Fonts and FontAwesome
  • Light and dark themes

Miscellaneous

  • Accessibility
  • Analytics and usage services
  • Build performance and size
  • Read the Docs functionality
  • User Guide
  • Navigation depth and collapsing sidebars

Navigation depth and collapsing sidebars#

By default, this theme enables to expand/collapse subsections in the primary sidebar navigation (without actually navigating to the page itself), and this extends up to 4 levels deep:

../_images/demo-expandable-navigation.gif

Control how many navigation levels are shown by default#

You can control how many navigation levels are shown when a page is loaded. By default, this level is 1, and only top-level pages are shown, with drop-boxes to reveal their children. To make their children show up by default, you can use the following configuration in conf.py:

html_theme_options = {
  "show_nav_level": 2
}

This will make the first two navigations show up by default (AKA, top-level pages and their immediate children).

Collapse entire toctree captions / parts#

If your toctree elements have captions assigned to them (with :caption:), you may collapse navigation items so that only the caption is visible. Clicking on the caption will display the items below.

To enable this behavior, set the show_nav_level value to 0, like below:

html_theme_options = {
   "show_nav_level": 0
}

You can only collapse your toctree items underneath their caption if a caption is defined for them! If your toctree does not have a caption defined, then all of the pages underneath it will be displayed (the same as the default theme behavior). See the toctree documentation for more details.

Note

In some Sphinx sites, the top-level toctree groupings make up “parts” in the documentation, with each page beneath making up a “chapter”.

Control the number of navigation levels#

In addition, you can also control how many levels of the navigation are shown in the sidebar (with a default of 4):

html_theme_options = {
  "navigation_depth": 2
}

Remove reveal buttons for sidebar items#

It is possible to turn off the expandable navigation entirely by setting the collapse_navigation config option to True:

html_theme_options = {
  "collapse_navigation": True
}

previous

Theme Structure and Layout

next

Page Table of Contents

On this page
  • Control how many navigation levels are shown by default
    • Collapse entire toctree captions / parts
  • Control the number of navigation levels
  • Remove reveal buttons for sidebar items
Edit on GitHub
Show Source

© Copyright 2019, PyData Community.

Created using Sphinx 5.3.0.

Built with the PyData Sphinx Theme 0.13.2dev0.