Skip to content

Add singlehtml_embed_assets option for self-contained singlehtml output - #14661

Open
cyclomati wants to merge 1 commit into
sphinx-doc:masterfrom
cyclomati:singlehtml-embed-assets
Open

Add singlehtml_embed_assets option for self-contained singlehtml output#14661
cyclomati wants to merge 1 commit into
sphinx-doc:masterfrom
cyclomati:singlehtml-embed-assets

Conversation

@cyclomati

Copy link
Copy Markdown

Purpose

Adds an opt-in singlehtml_embed_assets configuration option to the singlehtml builder. When enabled, local CSS and JavaScript are inlined and local images and favicons are converted to data URIs, producing a self-contained HTML file that can be shared or emailed without accompanying asset files. External resources are left unchanged, and the option defaults to disabled to preserve existing behavior. This includes tests, documentation, and a changelog entry. Currently, srcset images and assets referenced by video/object tags are not embedded.

References

AI Disclosure

Claude Code (Claude Fable 5) was used to write the implementation, tests, and documentation in this PR; the commit carries a Co-Authored-By trailer accordingly. I reviewed the change and wrote this description myself, and the PR is submitted from my account at my direction.

…file

When enabled, the singlehtml builder rewrites the generated page after
the build so that local stylesheets, scripts, images, and icons are
embedded directly into the HTML file, producing a self-contained single
file that can be shared without its accompanying asset files.

Local stylesheets become inline <style> elements (with local @import
rules and url(...) references embedded as well), local scripts become
inline <script> elements, and images and icons are embedded as data:
URIs. External (e.g. https://) references are left untouched.

The option is off by default, so existing behaviour is unchanged.

See sphinx-doc#10688

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013KAcg7m7GR5XMPhw8k3uzC
@jdillard jdillard added the type:proposal a feature suggestion label Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:proposal a feature suggestion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow singlehtml to embed all assets into a single html file

2 participants