diff --git a/docs/conf.py b/docs/conf.py index a79e750b8..8f4561d96 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -129,6 +129,7 @@ "logo": { "text": "PyData Theme", "image_dark": "logo-dark.svg", + "alt_text": "PyData Theme", }, "use_edit_page_button": True, "show_toc_level": 1, diff --git a/docs/user_guide/branding.rst b/docs/user_guide/branding.rst index 60e2e0f43..9ce7c290f 100644 --- a/docs/user_guide/branding.rst +++ b/docs/user_guide/branding.rst @@ -74,6 +74,22 @@ To reference an external website, make sure your link starts with ``http``: } } +Customize logo alternative text +------------------------------- + +You may set a custom ``alt text`` to use with your logo to replace the default ("logo image"). +This can make the logo more accessible to those using screen readers or other assistive tech. +To do so, use ``html_teme_options["logo"]["alt_text"]`` as in the following example: + +.. code-block:: python + :caption: conf.py + + html_theme_options = { + "logo": { + "alt_text": "foo", + } + } + Add a logo title ---------------- diff --git a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/navbar-logo.html b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/navbar-logo.html index 7b5773e0c..70868c836 100644 --- a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/navbar-logo.html +++ b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/navbar-logo.html @@ -1,22 +1,24 @@ {% if not theme_logo.get("link") %} {% set href = pathto(root_doc) %} {% elif theme_logo.get("link").startswith("http") %} - {# Logo link is to external URL #} - {% set href = theme_logo.get("link") %} + {% set href = theme_logo.get("link") %} {# external url #} {% else %} - {# Logo link is to internal page #} - {% set href = pathto(theme_logo.get("link")) %} + {% set href = pathto(theme_logo.get("link")) %} {# internal page #} {% endif %}