add print.css as a separate, lazy-loaded stylesheet#6
Merged
Arty2 merged 2 commits intoclaude/polish-passfrom Apr 29, 2026
Merged
add print.css as a separate, lazy-loaded stylesheet#6Arty2 merged 2 commits intoclaude/polish-passfrom
Arty2 merged 2 commits intoclaude/polish-passfrom
Conversation
A dedicated `assets/styles/print.css` linked with `media="print"`.
Browsers natively defer non-matching media, so the file is fetched
lazily — only when the user actually prints (or print-previews).
Screen readers and the average page load pay nothing.
A separate sheet (rather than an inline `@media print` block in
`screen.css`) keeps the default stylesheet focused, makes overrides
trivial via a custom `static/styles/custom-print.css`, and lets the
browser drop the rules from memory when not in use.
Rules:
* Flat, ink-saving palette — overrides every theme's HSL channels at
`:root` and forces `body` to black-on-white.
* Single-column layout — `max-width: none` on `body > header`,
`main`, `body > footer`.
* Hides chrome with no value on paper: `.gadgets`, `.languages`,
`nav`, `.taxonomy-filter`, `#search__form`, `.menu-social`,
`.share`. Generic escape hatch: `[data-print="hide"]`.
* Expands `http(s)` and protocol-relative hyperlinks to footnote-style
URLs via `a::after { content: " (" attr(href) ")" }` so they survive
the page. Same-page anchors and `mailto:`/`tel:` stay clean.
* Page-break hints: `break-after: avoid` on h1–h6, `break-inside:
avoid` on `figure`, `pre`, `blockquote`, `.alert`.
* Drops decorative effects (`mix-blend-mode`, `filter`, hover
outlines) that print poorly.
Wired through Hugo's existing asset pipeline (`resources.Get | minify
| fingerprint`) with SRI integrity, mirroring how `screen.css` and
`syntax.css` are already loaded.
https://claude.ai/code/session_01LAYiVF9Z1tk1PW3UAZz1Wb
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Stacked on #5. A dedicated print stylesheet — long enough that an inline
@media printblock insidescreen.csswould bloat the screen-default sheet, but small enough that a separate file is cheap. Browsers natively defermedia-mismatched stylesheets, soprint.cssis fetched lazily only when the user actually prints (or print-previews). The on-screen page load pays nothing.A separate sheet also makes overrides trivial: a site author can drop
static/styles/custom-print.cssnext tocustom.csswithout parsingscreen.css.(F1–F4 from the original audit — reading time, OG image dimensions, dark-mode favicon, apple-touch-icon — were dropped per maintainer call.)
What
New file
assets/styles/print.css::rootoverride every theme;bodyforced black-on-whitemax-width: none+ zero margin onbody > header,main,body > footerfor a single column.gadgets,.languages,nav,.taxonomy-filter,#search__form,.menu-social,.share; plus a generic[data-print="hide"]escape hatcha[href^="http"]::after { content: " (" attr(href) ")" }expands URLs to footnote-style. Same-page anchors andmailto:/tel:stay cleanbreak-after: avoidon h1–h6;break-inside: avoidonfigure,pre,blockquote,.alertmix-blend-mode,filter, hover outlineslayouts/partials/head.html: new<link rel="stylesheet" media="print">emitted alongside the existingscreen.css/syntax.css. Goes through the sameresources.Get | minify | fingerprintpipeline; emits the integrity attribute exactly like the other sheets.Test plan
cd exampleSite && hugo --gc --minify— cleanpublic/styles/print.min.<hash>.cssproduced<link rel=stylesheet href=/styles/print.min….css integrity="sha256-…" crossorigin=anonymous media=print>(verified inpublic/index.html)npx html-validate@^9 --config .github/html-validate.json public/**/*.html— exit 0print.cssshows aslowestpriority and (in some browsers) listed but not blocking; Browser Print Preview shows the print rules applied[data-print="hide"]element disappears in print preview; on-page hyperlinks expand toAnchor text (https://…); figures/pre blocks don't split across pagesStacking
Base is
claude/polish-pass(#5). Once #5 lands, GitHub will automatically retarget this PR tomaster.Generated by Claude Code