Repository navigation
H2: read the homepage's linked pages before warning nothing uses /_next/image - #13
Merged
Merged
Conversation
…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.
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.
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 wherenext/imageusually is.animalhouse.ai's sitemap has 715 URLs, nearly all pet and agent pages.
/how-it-worksusesnext/image(withoutunoptimized), and it's never in the sample, so every run said: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:
homeLinks()(inhelpers.mjs, tested) lists a homepage's same-site page links: no assets,/_next/files, fragments, queries or other origins, each once.get(), at most four at a time...., nor the 3 more the homepage links to).Tests
gallery(40 generated pages, one linked page using the optimizer: H2 skips) andgalleryunlinked(the same without the link: H2 still warns). The end-to-end test fails on the old code.npm test: 67 pass.🤖 Generated with Claude Code