Adding Logo and Favicon to Sphinx#

A new step in my blog, I decided to leave a personal touch through a logo, something simple but distinctive from pre-downloaded images like before, and which is why I hadn’t configured it yet. I’ll tell you how to configure the logo and favicon for Sphinx.

Assets Directory#

To start, we need to configure the directory that will hold our static files for the logo and favicon. In our configuration file, conf.py, we’ll adjust the value of the html_static_path variable, as explained in a previous publication.

This step is especially important if you host your blog on GitHub, since the default value doesn’t allow files with a leading _ to be loaded during deployment.

Favicon#

For the favicon as well, we can use Sphinx’s own options with the variable html_favicon. Our favicon must be 16x16 pixels in size and can be in ICO, PNG, SVG, or GIF format.

Due to the square size of the favicon, which will appear in browser tabs or bookmarks, it’s convenient to have a second design based on our logo that adapts to these dimensions.

So, in our conf.py file, we make the adjustment:

html_logo = 'static/cosmoscalibur_favicon.png'

Now, the favicon published.

Square favicon icon in tab browser.

Our favicon icon in tab browser.#

Referencias#