Skip to content

Discover and link site favicons from the default partial, and add an icon-generation helper - #2654

Merged
chalin merged 3 commits into
docsy:mainfrom
chalin:chalin-m24-favicon-smart-partial-2026-0613
Jun 14, 2026
Merged

chalin merged 3 commits into
docsy:mainfrom
chalin:chalin-m24-favicon-smart-partial-2026-0613

Conversation

@chalin

@chalin chalin commented Jun 14, 2026 •

Copy link
Copy Markdown
Collaborator

What changed:

  • Replaces the theme's empty favicons.html with a default partial that discovers and links the conventionally named favicons a site publishes via static/ (favicon.ico, favicon.svg, favicon-32x32.png, favicon-16x16.png, apple-touch-icon.png); a site that drops these files in static/ gets the matching <link> tags with no partial and no config
    • Uses relURL so hrefs stay correct under a baseURL subpath
    • Emits links via safeHTML so the + in image/svg+xml is not escaped to &#43;
  • Adds scripts/gen-favicons.sh, which derives favicon.ico and apple-touch-icon.png from a single source SVG via ImageMagick (the formats Hugo cannot produce), with a companion test that skips when ImageMagick is absent
  • Converges docsy.dev onto the theme default by dropping its bespoke partial; the existing golden test confirms the built output is byte-identical
  • Extends the theme-defaults tests with discovery cases (single file, full set, absent files, baseURL subpath)
  • Rewrites the "Add your favicons" user guide for the zero-partial convention and adds a changelog entry

…icon-generation helper

- Contributes to docsy#2357
- Replaces the theme's empty default favicons partial with one that discovers and links the conventionally named favicons a site publishes via `static/` (`favicon.ico`, `favicon.svg`, the 16/32px PNGs, `apple-touch-icon.png`), so most sites need no favicons partial and no config; still ships no icon artwork of its own, honoring docsy#2595
- Uses `relURL` so the emitted hrefs stay correct under a `baseURL` subpath, and `safeHTML` so the `+` in `image/svg+xml` is not escaped to `&docsy#43;`
- Converges docsy.dev onto the theme default by dropping its bespoke partial; the golden test confirms byte-identical output
- Adds `scripts/gen-favicons.sh` to generate `favicon.ico` and `apple-touch-icon.png` from a source SVG (the formats Hugo cannot produce), with a companion test that skips when ImageMagick is absent
- Extends the theme-defaults tests with discovery cases (single file, full set, absent files, `baseURL` subpath)
- Rewrites the "Add your favicons" user guide for the zero-partial convention and adds a changelog entry
@chalin
chalin force-pushed the chalin-m24-favicon-smart-partial-2026-0613 branch from e08cfb7 to 7d25877 Compare June 14, 2026 11:35
@chalin chalin changed the title Add a smart default favicons partial and an icon-generation helper Discover and link site favicons from the default partial, and add an icon-generation helper Jun 14, 2026
- Contributes to docsy#2357
- Clarifies in the user guide that gen-favicons.sh writes only the raster icons, so an SVG favicon must be copied to static/favicon.svg manually
- Cross-references the New favicon-discovery entry from the Breaking default-favicons bullet in the changelog
- Releads the New changelog entry with the documented "you can now..." past-tense phrasing
- Adds a test that locks the optional favicon-16x16.png / favicon-32x32.png discovery rows
- Drops a stray "smart" qualifier from a test comment
- Contributes to docsy#2357
- Asserts the gen-favicons.sh output contract in its test: favicon.ico bundles the 16/32/48px frames and apple-touch-icon.png is 180x180, via magick identify (still skipped when ImageMagick is absent)
- Reword the user guide to "covers common browser and platform favicon needs" instead of "practically every browser"
@chalin
chalin merged commit c0f2ddc into docsy:main Jun 14, 2026
15 checks passed
@chalin
chalin deleted the chalin-m24-favicon-smart-partial-2026-0613 branch June 14, 2026 12:28
chalin added a commit to chalin/docsy-example that referenced this pull request Jun 14, 2026
- Contributes to docsy/docsy#2357
- Adds `favicon.svg`, `favicon.ico`, and `apple-touch-icon.png` under `static/` so the Docsy theme's default favicons partial discovers and links them; the example lost its favicon when docsy/docsy#2653 dropped the theme's bundled defaults
- Reuses docsy.dev's favicon assets verbatim -- all three files are byte-identical to docsy.dev's so the example provably uses the same Docsy-logo artwork it already shows in its navbar
- Bumps the Docsy theme module to a commit that includes the discovery partial (docsy/docsy#2654)
- Adds `tests/favicons.test.mjs` asserting the three discovered `<link>`s render in the built home page
@chalin chalin added this to the 0.16.0 milestone Jun 26, 2026
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.

1 participant