On this page

Options

The theme options a site sets in html_theme_options in conf.py. Each is described the same way: its type, its default and what it does.

A component list is a Python list of names, and a name may be written with or without .html. These are the same:

html_theme_options = {
    "footer_start": ["copyright", "sphinx-version"],
}
html_theme_options = {
    "footer_start": ["copyright.html", "sphinx-version.html"],
}

Each name is a template. The theme looks for it in its own components/ directory first, then in the site’s templates_path. A name that no template has draws nothing and raises no warning. Components lists the ones the theme provides.

Layout

layout

  • Type: string

  • Default: "hHh LpR lff"

  • Meaning: The layout code. It places the header, the primary sidebar, the page, the secondary sidebar and the footer, and sets which of them stay in view while the page scrolls. An empty value means the default. A value that is not a layout code stops the build with a message naming the option. The layout code explains each letter.

Brand

The brand is the logo and name at the start of the navbar. When layout gives the top-left corner to the primary sidebar, the brand heads that sidebar on wide screens and stays in the navbar on narrow ones. A logo is a full address, a path starting _static/, or a path relative to _static. Sphinx’s html_logo is used for both modes when logo gives no image.

Modes and themes

A reader sees the site in a mode: light, dark, or the one their system asks for. Each mode draws one daisyUI theme. The theme-switcher component lets a reader choose. Choose the themes shows the steps.

light_theme

  • Type: string

  • Default: "light"

  • Meaning: The theme the light mode draws. The name is used as given, so a theme of the site’s own works as well as one of daisyUI’s.

dark_theme

  • Type: string

  • Default: "dark"

  • Meaning: The theme the dark mode draws. The name is used as given.

default_mode

  • Type: string

  • Default: "auto"

  • Meaning: The mode a reader sees before they have chosen one. The values are "auto", which follows the system’s setting, "light" and "dark". Any other value builds with a warning and means "auto". A reader’s own choice replaces it, and the browser remembers that choice.

theme_picker

  • Type: boolean, string or list of strings

  • Default: empty, which offers no theme by name

  • Meaning: The themes the theme menu lists besides the three modes. True or "all" lists every theme the stylesheet holds. A list of names, or one string with the names separated by commas, lists those in the order given, each once. An empty value, False or "false" lists none. A name is accepted as given, so a site’s own theme can be named.

Moving between pages

show_prev_next

  • Type: boolean

  • Default: True

  • Meaning: Whether each page ends with links to the previous and the next page in the site’s table of contents. A page with neither, and the search and index pages, show none.

back_to_top_button

  • Type: boolean

  • Default: True

  • Meaning: Whether a button appears while the reader scrolls up, far down a page, that scrolls back to the top.

announcement

  • Type: text

  • Default: empty

  • Meaning: A banner across the top of every page. Text, including HTML of your own, is printed as written and is not escaped. Text that starts with http:// or https:// is an address instead: the page script fetches it and puts the HTML it returns in the banner. The banner is removed when the address cannot be fetched, answers with an error or returns nothing, which includes a site opened from the file system. An empty value shows no banner.

sticky_banners

  • Type: boolean

  • Default: False

  • Meaning: Whether the banner sits inside the header, so that it stays with the header when the layout code keeps the header in place. When off, the banner is the first thing on the page and scrolls away.

Versions

The theme draws a version menu in the header when a site names the file that lists its versions. Set up versions shows the steps.

switcher

  • Type: dictionary with json_url and version_match

  • Default: {}, which draws no menu and no banner

  • Meaning: json_url is where the file listing every version is. version_match is the version this build documents. It labels the menu and picks the entry the reader is on. The menu is drawn on every page only when json_url is set.

json_url takes three forms:

  • A full address, such as https://example.org/switcher.json, or one starting with //, which is read as https:.

  • A path from the server’s root, such as /switcher.json.

  • Any other path, such as _static/switcher.json, which is read from the site’s root.

A version’s url in the file takes the same three forms. A path from the server’s root is used as given, and any other path is read from the site’s root, so one file serves a page at any depth. The check described under check_switcher reads a path in json_url from the build’s output, where a path from the server’s root is read as from the site’s root.

check_switcher

  • Type: boolean

  • Default: True

  • Meaning: Whether the build reads the file at json_url once, at the end of the build, and warns when it cannot be read or is not a list of versions each with a version and a url. The build still succeeds. A path is read from the built site, so a file in a static directory is found after the build copies it. When False, the file is never read.

show_version_warning_banner

  • Type: boolean

  • Default: False

  • Meaning: When True and json_url is set, every page carries a banner before the header that appears on any version other than the preferred one and links to the preferred one.

On this page

The page-toc component lists the headings of the page being read.

show_toc_level

  • Type: integer

  • Default: 2

  • Meaning: How many levels of headings are listed at all times. Headings deeper than that stay hidden until the section above them is being read. A level of 1 lists only the headings directly under the page’s title, a level of 2 lists the headings under those as well, and a level larger than the page’s deepest heading lists them all.

Component lists

article_header_start

  • Type: list of component names

  • Default: "breadcrumbs"

  • Meaning: The components at the start of the line above the page’s content. The line is left out when this list and article_header_end are both empty.

article_header_end

  • Type: list of component names

  • Default: empty

  • Meaning: The components at the end of the line above the page’s content.

article_footer_items

  • Type: list of component names

  • Default: empty

  • Meaning: The components directly below the page’s content.

primary_sidebar_end

  • Type: list of component names

  • Default: empty

  • Meaning: The components at the end of the primary sidebar, after Sphinx’s own sidebar templates.

secondary_sidebar_items

  • Type: list of component names

  • Default: "page-toc"

  • Meaning: The components in the secondary sidebar. The sidebar is left out when the list is empty, and on the search page and every index page.

Pygments styles

By default code is drawn with the theme’s token colours. These two options give a mode a Pygments style instead. Sphinx’s own pygments_style setting is not used: the theme drops Sphinx’s Pygments stylesheet from every page.

pygments_light_style

  • Type: string

  • Default: empty, which keeps the theme’s token highlighting

  • Meaning: The name of the Pygments style code uses in light mode, such as "friendly". The style follows the mode the page shows, and the system’s colour scheme until the page has a mode. A name that is not a Pygments style is reported as a warning of type daisyui and subtype pygments, and the mode keeps the theme’s token highlighting.

pygments_dark_style

  • Type: string

  • Default: empty, which keeps the theme’s token highlighting

  • Meaning: The name of the Pygments style code uses in dark mode, such as "monokai". It follows the mode the page shows in the same way as pygments_light_style, and an unknown name is handled in the same way.

html_theme_options = {
    "pygments_light_style": "friendly",
    "pygments_dark_style": "monokai",
}