Skip to content

H2: read the homepage's linked pages before warning nothing uses /_next/image - #13

Merged
twinsgeeks merged 1 commit into
mainfrom
fix/h2-find-image-use
Oct 24, 2026
Merged

twinsgeeks merged 1 commit into
mainfrom
fix/h2-find-image-use

Conversation

@twinsgeeks

Copy link
Copy Markdown
Member

From animalhouse.ai, where H2 warned on every run although the endpoint is in use. Released as 1.2.5 in the CHANGELOG; fewer false warnings, no check newly fails.

The false warning

H2 reads a sample of 10 sitemap pages, spread evenly with spread(), and warns when none of them uses /_next/image. On a site whose sitemap is mostly generated pages, that sample misses the few hand-built pages, which is where next/image usually is.

animalhouse.ai's sitemap has 715 URLs, nearly all pet and agent pages. /how-it-works uses next/image (without unoptimized), and it's never in the sample, so every run said:

WARN  H2  Unused framework endpoints refused   Next.js: /_next/image answers 400, and none of the 10 pages read uses it (of 715 in the sitemap). If no page uses it, answer 404 so the next advisory in that endpoint can't reach you; ...

Following that advice would have broken the page. The site already noted H2 as "doesn't apply" in its docs, but a required check that warns every run trains people to ignore it.

The fix

When H2 would warn, it first reads up to 10 pages the homepage links to that the sample missed, and skips when one uses the endpoint:

skip  H2  Unused framework endpoints refused   Next.js: /how-it-works uses /_next/image, so it's in use; keep the framework patched (H3)
  • homeLinks() (in helpers.mjs, tested) lists a homepage's same-site page links: no assets, /_next/ files, fragments, queries or other origins, each once.
  • Up to 10 more requests, only on a Next.js site whose optimizer is live and that the sample didn't find in use. They're GETs of the site's own pages, through get(), at most four at a time.
  • When the warning stays, it says how many linked pages it read (..., nor the 3 more the homepage links to).
  • STANDARD.md H2's scorecard paragraph, and the request counts in STANDARD.md §1 and the README, describe it.

Tests

  • New fixture sites gallery (40 generated pages, one linked page using the optimizer: H2 skips) and galleryunlinked (the same without the link: H2 still warns). The end-to-end test fails on the old code.
  • npm test: 67 pass.
  • Against our own sites: animalhouse.ai goes from 8 of 9 required to 8 of 8; drifts.bot (its sample already finds a page using it) and achurch.ai (not Next.js) are unchanged.

🤖 Generated with Claude Code

…xt/image

The sample of 10 sitemap pages is spread evenly, so on a site whose sitemap is
mostly generated pages it misses the few hand-built ones, which is where
next/image usually is. animalhouse.ai's sitemap has 715 URLs, nearly all pet
and agent pages; /how-it-works uses the optimizer and was never sampled, so H2
warned on every run and suggested a 404 that would break that page.

When H2 would warn, it now reads up to 10 pages the homepage links to that the
sample missed (homeLinks(): same-site page links, no assets, framework files,
fragments or queries), and skips when one uses the endpoint. Up to 10 more
requests, only on a Next.js site with a live optimizer the sample didn't find in
use. The warning, when it stays, says how many linked pages it read.

New fixtures gallery (H2 skips) and galleryunlinked (H2 warns); the end-to-end
test fails on the old code. STANDARD.md H2 and the request counts in STANDARD.md
§1 and the README say so. 1.2.5.

Checked: npm test (67 pass); animalhouse.ai goes from 8 of 9 required to 8 of 8
(H2: "/how-it-works uses /_next/image"); drifts.bot and achurch.ai unchanged.
@twinsgeeks
twinsgeeks merged commit 1c70bff into main Oct 24, 2026
3 checks passed
@twinsgeeks
twinsgeeks deleted the fix/h2-find-image-use branch October 24, 2026 05:05
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