Change the favicon of the Sphinx Read The Docs theme?
Asked Answered
D

2

33

I'm already using a custom css to override some of the styles of the theme using

def setup(app):
    app.add_css_file('custom.css')

This works fine. What other app. functions are available? I can't find any documentation.

I'm looking for the function to override the favicon.

Doth answered 11/2, 2019 at 21:8 Comment(3)
It's in your theme's template. You can override theme files.Boarer
Thanks @StevePiercy for your reply. Can you show me how I can override theme files? Or do I need to download the full theme and make a custom version? I would like to avoid that.Doth
It depends on the theme. For both included and installable themes, SO has many posts or consult Sphinx docs.Boarer
D
39

Thanks to @StevePiercy I found this documentation: https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_favicon

conf.py

html_favicon = 'favicon.ico'

I put favicon.ico in my source folder, next to my .rst-files and it is working as expected: https://global-coffee-data-standard.readthedocs.io/en/latest/index.html

Doth answered 13/2, 2019 at 8:24 Comment(4)
Edited to .ico file extension. it failed with pngEthnic
For me, a file called favicon.png worked perfectly fine. Not sure why it didn't work for you.Teach
In the root folder of the project? Or the docs/ folder?Keratosis
This doesn't work for me on github.io but works locally :/Keratosis
H
1

In addition to Sphinx's native favicon support (https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_favicon), you can also use this Sphinx extension I created: https://pypi.org/project/sphinx-favicon/ With this extension, you can add multiple favicons, including apple-touch-icon and icons of different sizes. You can also use PNG or other supported file types.

Holland answered 8/10, 2021 at 18:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.