Skip to main content

Sphinx Extension adding support for custom favicons

Project description

Sphinx Favicon

License: MIT Black badge PyPI PyPI - Python Version GitHub Workflow Status Read the Docs (version)

Note: Updating from Version 0.2 to Version 1.0

Between v0.2 and v1.0, the module name of the extension changed to better conform with Python standards. Please update the name used in the extension list of your conf.py from sphinx-favicon to sphinx_favicon!

A Sphinx extension to add custom favicons

With Sphinx Favicon, you can add custom favicons to your Sphinx html documentation quickly and easily.

You can define favicons directly in your conf.py, with different rel attributes such as "icon" or "apple-touch-icon" and any favicon size.

The Sphinx Favicon extension gives you more flexibility than the standard favicon.ico supported by Sphinx. It provides a quick and easy way to add the most important favicon formats for different browsers and devices.

Installation

Use pip to install Sphinx Favicon in your environment:

pip install sphinx-favicon

Usage

After installing sphinx-favicon, add it to your conf.py extension list:

extensions = ["sphinx_favicon"]

Then configure the favicon links using the favicons parameter (html_static_path is mandatory if you use relative path):

html_static_path = ["_static"]

favicons = [
    {"href": "icon.svg"},  # => use `_static/icon.svg`
    {"href": "https://secure.example.com/favicon/favicon-16x16.png"},
    {"href": "https://secure.example.com/favicon/favicon-32x32.png"},
    {
        "rel": "apple-touch-icon",
        "href": "https://secure.example.com/favicon/apple-touch-icon-180x180.png",
    },
]

Based on this configuration, Sphinx will include the following favicon information in the HTML <head> element:

<link rel="icon" href="_static/icon.svg" type="image/svg+xml">
<link rel="icon" href="https://secure.example.com/favicon/favicon-16x16.png" sizes="16x16" type="image/png">
<link rel="icon" href="https://secure.example.com/favicon/favicon-32x32.png" sizes="32x32" type="image/png">
<link rel="apple-touch-icon" href="https://secure.example.com/favicon/apple-touch-icon-180x180.png" sizes="180x180" type="image/png">

For more details and more advanced usage, please see the documentation.

Contribution

Contributions of any kind are welcome. Please see the contribution section of our documentation for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sphinx-favicon-1.0.1.tar.gz (8.2 kB view hashes)

Uploaded source

Built Distribution

sphinx_favicon-1.0.1-py3-none-any.whl (7.0 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page