Skip to content

Serve the docs gallery from web-sized images so Google can fetch it - #228

Merged
patrickchugh merged 2 commits into
mainfrom
docs/gallery-web-sized-images
Oct 4, 2026
Merged

patrickchugh merged 2 commits into
mainfrom
docs/gallery-web-sized-images

Conversation

@patrickchugh

Copy link
Copy Markdown
Owner

Type of Change

  • Bug Fix
  • New Feature
  • Refactor
  • Documentation

What and why

Google Search Console's "Test live URL" and "Request indexing" both failed on /gallery/ with "Something went wrong", while lighter pages on the same site passed. Measuring the page confirmed it was very heavy: it embedded twelve full-size PNGs straight from raw.githubusercontent.com.

Images on the gallery page Total weight
Before 12 PNGs, 5,216 to 11,488 px wide 13.8 MB
After 12 WebPs, 1,400 px wide, served from the docs site 0.7 MB

Changes:

  • scripts/make_gallery_images.py reads every examples/graphs/*.png, trims the surrounding white space, scales it to at most 1,400 px wide and writes a WebP (quality 85) to docs/assets/gallery/<name>.webp. It records each source PNG's SHA-256 in docs/assets/gallery/sources.json, so it is safe to rerun and skips files that are already up to date without relying on file modification times.
  • The generated images are committed (15 files, 992 kB in total).
  • docs/gallery.md shows the web-sized image for each example with explicit width and height, loading=lazy on all but the first image, and the no-lightbox skip class from the glightbox configuration in mkdocs.yml. Each image is wrapped in a link to the full-size PNG, so a click still opens the original. Every heading, anchor id, prompt, command and download link is unchanged; the diff touches only the twelve image lines.
  • examples/graphs/README.md gains one line telling contributors to run the script after adding an example.
  • The gallery strip on docs/index.md was checked and left alone: its six thumbnails are 67 to 98 kB each, all under the 150 kB threshold.

Verification:

  • mkdocs build passes with no warnings, before and after.
  • All twelve /gallery/#... anchors linked from the README resolve in the built page.
  • The built page wraps none of the new images in a glightbox link.

Checklist

All Submissions:

  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Have you written Documentation/Tests?
  • Have you done your own code-review?
  • Have you disclosed any use of AI tools and models with their version?

AI Assistance Declaration

  • Tools used: Claude Code
  • Model: Claude Fable 5.1
  • Scope: Wrote scripts/make_gallery_images.py, generated the WebP images, rewrote the twelve image lines in docs/gallery.md, added the README line, and verified the build. Reviewed by the author.

Checklist for Changes to Core Features:

  • Have you discussed any major revamp with a reviewer/maintainer first? (It's okay to just raise a PR directly for minor bugfixes)
  • Have you ensured your PR is focused on one major improvement and is not trying to do too many changes at once?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable, and made sure the new tests PASS? (docs and a build script only; no core code changed)
  • Have you successfully run all previous system wide tests with your changes locally? (mkdocs build; core tests are unaffected)

🤖 Generated with Claude Code

patrickchugh and others added 2 commits October 4, 2026 15:13
scripts/make_gallery_images.py trims the white margin off every
examples/graphs/*.png, scales it to at most 1400 px wide and writes a
WebP copy to docs/assets/gallery/, recording the source hash in
sources.json so reruns skip files that are already up to date.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The gallery embedded twelve full-size PNGs from raw.githubusercontent.com,
about 13.8 MB in total, and Google Search Console could not fetch the
page. Each example now shows the web-sized WebP from docs/assets/gallery/
with explicit width and height, lazy loading on all but the first image
and the glightbox skip class, wrapped in a link to the full-size PNG.
The page's image weight drops to about 0.7 MB. Headings, anchors,
prompts, commands and download links are unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@patrickchugh
patrickchugh merged commit 78e6001 into main Oct 4, 2026
2 checks passed
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