@@ -77,40 +77,67 @@ To reference an external website, make sure your link starts with ``http``:
77
77
}
78
78
}
79
79
80
- Customize logo alternative text
80
+ Logo title and alternative text
81
81
-------------------------------
82
82
83
- You may set a custom ``alt text `` for your logo to replace the default ``"logo image" `` generic description.
84
- Adding a descriptive ``alt text `` can help make your documentation more accessible to readers using screen readers or another assistive tech.
85
-
86
- To do so, customize the ``html_theme_options["logo"]["alt_text"] `` configuration option as in the following example:
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:
87
86
88
87
.. code-block :: python
89
88
:caption: conf.py
90
89
91
90
html_theme_options = {
92
91
" logo" : {
93
- # Because the logo is also a homepage link, including "home" in the alt text is good practice
94
- " alt_text" : " My Project Name - Home" ,
92
+ " text" : " My awesome documentation" ,
93
+ " image_light" : " _static/logo-light.png" ,
94
+ " image_dark" : " _static/logo-dark.png" ,
95
95
}
96
96
}
97
97
98
- Add a logo title
99
- ----------------
100
-
101
- To add a title in the brand section of your documentation, define a value for ``html_theme_options.logo["text"] ``.
102
- This title will appear next to the logo image if set.
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:
103
101
104
102
.. code-block :: python
103
+ :caption: conf.py
105
104
106
105
html_theme_options = {
107
106
" logo" : {
108
- " text" : " My awesome documentation" ,
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" ,
109
112
}
110
113
}
111
114
112
- .. note :: The ``html_title`` field will work as well if no logo images are specified.
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
+ }
113
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 ``).
114
141
115
142
Add favicons
116
143
============
0 commit comments