Customization

There are two methods to alter the theme. The first, and simplest, uses the options exposed through html_theme_options in conf.py. This site’s options are:

104
105html_theme = "mdanalysis_sphinx_theme"
106
107extra_nav_links = {}
108extra_nav_links["MDAnalysis"] = "http://mdanalysis.org"
109extra_nav_links["MDAnalysis docs"] = "http://docs.mdanalysis.org"
110extra_nav_links["@mdanalysis"] = "https://twitter.com/mdanalysis"
111
112
113# material theme options (see theme.conf for more information)
114html_theme_options = {
115    # whether to apply official MDAnalysis styling
116    # e.g. using the official MDAnalysis logo and favicon
117    # and using the MDAnalysis privacy policy
118    "mda_official": True,
119    # Extra navigation links to show on the sidebar, before the table of contents
120    "extra_nav_links": extra_nav_links,
121    # The background colour of the logo area in the navigation bar
122    "sidebar_logo_background": "#ffffff",
123    # The background colour of the top navigation bar on mobile
124    "mobile_navbar_background": "dark-gray",
125
126    # other options inherited from sphinx_rtd_theme
127    # Only display logo and not the project name on sidebar
128    "logo_only": True,
129    # Display the version number on the sidebar
130    "display_version": True,
131    # Where to display "next" and "previous" buttons
132    "prev_next_buttons_location": "bottom",
133    # Add an icon next to external links
134    "style_external_links": False,
135    # If enabled, navigation entries are not expandable
136    "collapse_navigation": True,
137    # If enabled, the navigation bar scrolls with the main page
138    "sticky_navigation": True,
139    # Maximum depth of the contents tree -- set to -1 for unlimited
140    "navigation_depth": 4,
141    # Whether to include hidden toctrees in the navigation bar
142    "includehidden": True,
143    # Whether to hide page subheadings from navigation
144    "titles_only": False,
145}

Many of these settings are provided in this site as examples; for a minimalistic example, see MDAnalysis Sphinx theme Quickstart.

Configuration Options

mda_official

Whether to use official MDAnalysis styling. If True, this adds a footer with the MDAnalysis privacy policy and other common features. For example, if a logo and a favicon are not specified, the MDAnalysis logo and favicon are used.

sidebar_logo_background

The colour of the background of the logo in the sidebar. This can be a hex string (e.g. '#ffffff') or any of the named colours (mdanalysis-orange, mdanalysis-code-orange, white, dark-gray)

mobile_navbar_background

The colour of the top navigation header in mobile format. This can be a hex string (e.g. '#ffffff') or any of the named colours (mdanalysis-orange, mdanalysis-code-orange, white, dark-gray)

extra_nav_options

This is a dictionary of additional navigation links. They appear before the rest of the tables of contents in the sidebar. The keys are the labels of the links, and the values are the URLs.

Customizing the layout

You can customize the theme by overriding Jinja template blocks. For example, ‘layout.html’ contains several blocks that can be overridden or extended.

Place a ‘layout.html’ file in your project’s ‘/_templates’ directory.

mkdir source/_templates
touch source/_templates/layout.html

Then, configure your ‘conf.py’:

templates_path = ['_templates']

Finally, edit your override file source/_templates/layout.html:

{# Import the theme's layout. #}
{% extends '!layout.html' %}

{%- block extrahead %}
{# Add custom things to the head HTML tag #}
{# Call the parent block #}
{{ super() }}
{%- endblock %}

New Blocks

The theme has a small number of new blocks to simplify some types of customization:

footerrel

Previous and next in the footer.

fonticon

Block that contains the icon font. You should probably call {{ super() }} at the end of the block to include the default icon fonts as well. (Font Awesome and Academicons)