Skip to content

Add favicon to docs - #2317

Merged
hansthen merged 1 commit into
python-visualization:mainfrom
williambdean:docs-favicon
Oct 26, 2026
Merged

hansthen merged 1 commit into
python-visualization:mainfrom
williambdean:docs-favicon

Conversation

@williambdean

Copy link
Copy Markdown
Contributor

Summary

The docs site currently has no favicon: docs/conf.py was scaffolded by
sphinx-quickstart in 2013 and the html_favicon option has sat
commented out ever since.

This PR adds a favicon so the browser tab shows the folium leaf instead
of a generic page icon:

  • docs/_static/favicon.ico: the existing leaf logo centered on a
    square transparent canvas, exported at 16, 32, and 48 px
  • docs/conf.py: set html_favicon = "_static/favicon.ico"

Details

The source folium_logo.png is 100x180 (and non-square), so it can't be
used directly. The favicon pads it to a 180x180 transparent square
rather than cropping, to keep the full leaf shape.

html_favicon accepts the path relative to the source directory;
pydata-sphinx-theme emits the <link rel="icon"> tag, and the file is
picked up through the existing html_static_path = ["_static"]
setting.

Verified locally: full make html build succeeds and the built
index.html contains <link rel="icon" href="_static/favicon.ico"/>.

Script used to generate favicon.ico from folium_logo.png

Ran once with uv run (script has inline PEP 723 deps); the output
favicon.ico is committed, so the script isn't part of the repo.

# /// script
# requires-python = ">=3.10"
# dependencies = ["pillow>=10"]
# ///
"""Build favicon.ico: the folium leaf centered on a transparent
square."""

from pathlib import Path

from PIL import Image

HERE = Path(__file__).parent
logo = Image.open(HERE / "folium_logo.png").convert("RGBA")

# Center the 100x180 leaf on a square transparent canvas.
w, h = logo.size
pad = (h - w) // 2
square = Image.new("RGBA", (h, h), (0, 0, 0, 0))
square.paste(logo, (pad, 0))

square.save(HERE / "favicon.ico", sizes=[(16, 16), (32, 32), (48, 48)])
print("wrote favicon.ico")

The docs config came from a 2013 sphinx-quickstart and never set
html_favicon. Generate a square 180x180 transparent canvas holding the
folium leaf, and export a favicon.ico with 16, 32, and 48 px variants.
@hansthen
hansthen merged commit 94b6c3a into python-visualization:main Oct 26, 2026
15 of 16 checks passed
@hansthen

Copy link
Copy Markdown
Collaborator

@williambdean Again, thanks!

@williambdean
williambdean deleted the docs-favicon branch October 26, 2026 11:49

This branch was successfully deployed

1 active deployment
pypi — 139986cc Deployed Oct 25, 2026 by williambdean via packages #2009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants