| 1 |
================= |
| 2 |
Branding and logo |
| 3 |
================= |
| 4 |
|
| 5 |
Customize logo and title |
| 6 |
======================== |
| 7 |
|
| 8 |
By default, the theme will use the value of ``project`` on the left side of the header navigation bar. |
| 9 |
This can be replaced by a logo image, and optionally a custom ``html_title`` as well. |
| 10 |
|
| 11 |
Single logo for light and dark mode |
| 12 |
----------------------------------- |
| 13 |
|
| 14 |
To use a **local image file**, use ``html_logo`` as specified in the `Sphinx documentation <https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_logo>`__. |
| 15 |
The file must be relative to ``conf.py``. |
| 16 |
For example, if your documentation had a logo in ``_static/logo.png``: |
| 17 |
|
| 18 |
.. code:: python |
| 19 |
|
| 20 |
html_logo = "_static/logo.png" |
| 21 |
|
| 22 |
To use an **external link** to an image, make sure the ``html_logo`` begins with ``http``. |
| 23 |
For example: |
| 24 |
|
| 25 |
.. code:: python |
| 26 |
|
| 27 |
html_logo = "https://pydata.org/wp-content/uploads/2019/06/pydata-logo-final.png" |
| 28 |
|
| 29 |
Different logos for light and dark mode |
| 30 |
--------------------------------------- |
| 31 |
|
| 32 |
You may specify a different version of your logo image for "light" and "dark" modes. |
| 33 |
This is useful if your logo image is not adapted to a dark mode (light background, not enough contrast, etc...). |
| 34 |
|
| 35 |
To do so, use the ``logo["image_light"]`` and ``logo["image_dark"]`` options in ``html_theme_options``. |
| 36 |
For each, provide a path relative to ``conf.py`` like so: |
| 37 |
|
| 38 |
.. code-block:: python |
| 39 |
|
| 40 |
# Assuming your `conf.py` has a sibling folder called `_static` with these files |
| 41 |
html_theme_options = { |
| 42 |
"logo": { |
| 43 |
"image_light": "_static/logo-light.png", |
| 44 |
"image_dark": "_static/logo-dark.png", |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
.. note:: |
| 49 |
|
| 50 |
``image_light`` and ``image_dark`` will override the ``html_logo`` setting. |
| 51 |
If you only specify one of the light or dark variants, the un-specified variant will fall back to the value of ``html_logo``. |
| 52 |
|
| 53 |
Customize logo link |
| 54 |
------------------- |
| 55 |
|
| 56 |
The logo links to ``root_doc`` (usually the first page of your documentation) by default. |
| 57 |
You can instead link to a local document or an external website. |
| 58 |
To do so, use the ``html_theme_options["logo"]["link"]`` option and provide a new link. |
| 59 |
|
| 60 |
For example, to reference another local page: |
| 61 |
|
| 62 |
.. code-block:: python |
| 63 |
|
| 64 |
html_theme_options = { |
| 65 |
"logo": { |
| 66 |
"link": "some/other-page", |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
To reference an external website, make sure your link starts with ``http``: |
| 71 |
|
| 72 |
.. code-block:: python |
| 73 |
|
| 74 |
html_theme_options = { |
| 75 |
"logo": { |
| 76 |
"link": "https://pydata.org", |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
Logo title and alternative text |
| 81 |
------------------------------- |
| 82 |
|
| 83 |
If you provide a logo image, it replaces ``project`` or ``html_title`` in the |
| 84 |
header nav bar. If you want to display both your site's logo and title (or any |
| 85 |
other text) next to the logo, you provide it with the ``text`` property like so: |
| 86 |
|
| 87 |
.. code-block:: python |
| 88 |
:caption: conf.py |
| 89 |
|
| 90 |
html_theme_options = { |
| 91 |
"logo": { |
| 92 |
"text": "My awesome documentation", |
| 93 |
"image_light": "_static/logo-light.png", |
| 94 |
"image_dark": "_static/logo-dark.png", |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
But if you only want to display the logo and not the site title, then it's good |
| 99 |
practice to provide alt text, which helps blind visitors and others who rely on |
| 100 |
screen readers: |
| 101 |
|
| 102 |
.. code-block:: python |
| 103 |
:caption: conf.py |
| 104 |
|
| 105 |
html_theme_options = { |
| 106 |
"logo": { |
| 107 |
# Because the logo is also a homepage link, including "home" in the |
| 108 |
# alt text is good practice |
| 109 |
"alt_text": "My awesome documentation - Home", |
| 110 |
"image_light": "_static/logo-light.png", |
| 111 |
"image_dark": "_static/logo-dark.png", |
| 112 |
} |
| 113 |
} |
| 114 |
|
| 115 |
In most cases, you will provide either ``text`` or ``alt_text``, not both, but |
| 116 |
there are some circumstances in which it may make sense to provide both: |
| 117 |
|
| 118 |
.. code-block:: python |
| 119 |
:caption: conf.py |
| 120 |
|
| 121 |
html_theme_options = { |
| 122 |
"logo": { |
| 123 |
# In a left-to-right context, screen readers will read the alt text |
| 124 |
# first, then the text, so this example will be read as "P-G-G-P-Y |
| 125 |
# (short pause) Home A pretty good geometry package" |
| 126 |
"alt_text": "PggPy - Home", |
| 127 |
"text": "A pretty good geometry package", |
| 128 |
"image_light": "_static/logo-light.png", |
| 129 |
"image_dark": "_static/logo-dark.png", |
| 130 |
} |
| 131 |
} |
| 132 |
|
| 133 |
If you do not provide ``text`` or ``alt_text``, the theme will provide some |
| 134 |
default alt text (otherwise, your homepage link would appear to assistive tech |
| 135 |
as something like "Unlabeled image"). The default alt text is "`docstitle |
| 136 |
<https://www.sphinx-doc.org/en/master/development/templating.html#docstitle>`_ - |
| 137 |
Home", but if you provide a logo title (``text``) the default alt text will be an |
| 138 |
empty string (the assumption is that if you provide a logo title, the title is |
| 139 |
probably doing the work of the alt text, and as shown above, you can override |
| 140 |
this assumption by supplying both ``text`` and ``alt_text``). |
| 141 |
|
| 142 |
Add favicons |
| 143 |
============ |
| 144 |
|
| 145 |
``pydata_sphinx_theme`` supports the `standard sphinx favicon configuration <https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_favicon>`_, using ``html_favicon``. |
| 146 |
Support for complex and multiple favicons was dropped in version 0.15.3. Instead, use the `sphinx-favicon <https://sphinx-favicon.readthedocs.io/en/stable/>`__ extension. |
| 147 |
It provides the same functionality using more flexible parameters. |