Customizing¶
The following code snippets can be set in conf.py
to customize the
appearance of your docs.
Project Name & Logo¶
Project name should be set both in Sphinx and in the theme. Logo options are set for the theme.
# This is used by Sphinx in many places, such as page title tags.
project = "My Project"
# These are options specifically for the Wagtail Theme.
html_theme_options = dict(
project_name = "My Project",
logo = "img/wagtail-logo-circle.svg",
logo_alt = "Wagtail",
logo_height = 59,
logo_url = "/",
logo_width = 45,
)
GitHub Link¶
The GitHub link is used for generating an “Edit on GitHub” button on each page. As such it should point to your docs folder in your default branch.
html_theme_options = dict(
github_url = "https://github.com/wagtail/sphinx_wagtail_theme/blob/main/docs/"
)
Show Date Last Updated¶
This is a built-in Sphinx feature which will show the date the docs were last
rendered in the footer of your docs. Format strings for Python’s
strftime()
are valid here. To disable, set to None
html_last_updated_fmt = "%b %d, %Y"
Custom Fonts & CSS¶
The theme ships with Adobe’s Source Sans and Source Code Pro fonts. You can change these, or any other style of the docs, with a custom CSS file.
Enable custom static files in conf.py
:
# These folders are copied to the documentation's HTML output.
html_static_path = ["_static"]
# These paths are either relative to html_static_path
# or fully qualified paths (eg. https://...).
html_css_files = ["custom.css"]
Then in your _static/custom.css
file, import a font and override the
relevant rules:
/* Import from Google Fonts, a CDN, or files in your _static folder.
This Google Fonts import provides its own `@font-face` CSS;
if providing your own font files, you'll also need to
provide your own `@font-face` code. */
@import url("https://fonts.googleapis.com/css2?family=Roboto");
/* Main font used throughout the docs. */
body {
font-family: "Roboto", sans-serif;
}
/* Code snippets. */
pre, code, kbd, samp {
font-family: "Courier New", monospace;
}