About the Sphinx Pythia Theme#

The Sphinx Pythia Theme is a Sphinx Theme that inherits directly from the Sphinx Book Theme used by the amazing Jupyter Book project. As a result, the Sphinx Pythia Theme, through the Sphinx Book Theme, inherits from the awesome PyData Sphinx Theme, which provides a great deal of functionality.

On top of all of these amazing themes, the Sphinx Pythia theme add a few simple new features.

Top Navigation Bar#

The Sphinx Pythia Theme brings back the fixed top navigation bar provided by the PyData Sphinx Theme. Where the Sphinx Book Theme places your html_logo at the top of the left sidebar, the PyData Sphinx Theme places the logo on the left of the top navigation bar. The PyData Sphinx Theme allows the user to set the link attached to the logo with the logo_link option in your Sphinx html_theme_options dictionary. You can learn how to customize your logo on the PyData Sphinx Theme documentation.

The links on the navigation bar can be set with the html_theme_options navbar_links option. This is a list of dictionaries containing a name key, url key, and an external key. The name key can be any string that you want to appear in the navbar. The url key is a string containing the URL that should be associated with the name in the navbar, and the external key is a boolean indicating if the link is external or not. (If external, an icon will be displayed next to the name in the navbar indicating that clicking the link takes you away from the site). Additionally, the external links (external_links) option from the PyData Sphinx Theme still works, and these links will be displayed after any links specified by the navbar_links option.

html_theme = 'sphinx_pythia_theme'
html_theme_options = {
    'navbar_links': [
        {'name': 'Link1',
         'url': 'https://link1.com/some/link',
         'external': True},
        {'name': 'Link2',
         'url': 'https://link2.com/some/other/link'},
    ]
}
sphinx:
  config:
    html_theme: sphinx_pythia_theme
    html_theme_options:
      navbar_links:
        - name: Link1
          url: https://link1.com/some/link
          external: True
        - content: Link2
          url: https://link2.com/some/other/link

Note

The url value can be a Sphinx document name, in addition to an absolute or relative URL. In fact, using Sphinx document names is the best way of generating the link correctly on different pages.

Icons can be displayed in the top right of the navigation bar using the PyData Sphinx Theme’s icon links customization (icon_links) option or by using the built-in PyData Sphinx Theme icon link shortcuts.

Special Page layouts#

The Sphinx Pythia Theme comes with two special layouts for pages: the banner layout, and the standalone layout.

Standalone Pages#

Standalone pages use the page-standalone.html template in the same way that the banner pages above use the page-banner.html template. Standalone pages have the same heading and text styling used by banner pages, but they do not have extra padding nor the ability to declare banner backgrounds to the sections. The Standalone Pages page is an example of this layout.

Custom Templates#

The Sphinx Pythia Theme uses certain custom templates to define how the content in certain sections of the page will display. For the links in the top navigation bar, the navbar-menu.html template is used. For how to define banner and standalone page layouts, the page-banner.html and the page-standalone.html templates are used. For footer content, the footer-logos.html, footer-info.html, footer-menu.html, and the footer-extra.html templates are used.

Anyone can override these templates by putting their own versions of these templates (i.e., using the same template filenames) in a _templates directory within their Sphinx or Jupyter Book source (at the same level as their conf.py or _config.yml files).