Skip to content

feat(rules): core/canonical flags a page whose canonical points at the home page - #1700

Closed
nc9 wants to merge 3 commits into
mainfrom
feat/canonical-to-home-1685
Closed

nc9 wants to merge 3 commits into
mainfrom
feat/canonical-to-home-1685

Conversation

@nc9

@nc9 nc9 commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Closes #1685

What

A template that hard-codes the canonical to the site root tells search engines every page it renders duplicates the home page. The URL is well formed, so core/canonical passed it. A new canonical-to-homepage check, emitted only when a page is flagged, catches it. The logic is one pure function, homepageCanonicalVerdict(pageUrl, canonical), returning error, locale-home or none, with a table test.

  • error (check status fail): a page that is not the home page canonicals to the site root. The message names the page URL and the canonical; details carry pageUrl, canonical and source (tag or header).
  • locale-home (warn): a locale home page (one locale segment: /en/, /de, /pt-br/) canonicals to /.
  • none: the home page itself, a canonical to any other URL, another site's root, a root with a query (/?page_id=5 is a real page), and a page that redirected to the home page (the verdict is taken on the URL the page ended on, as the existing check does).
  • Root variants are one root: trailing slash, /index.html, the www and bare form of the host, http or https, and a fragment is ignored.
  • The Link header canonical is read like the tag (tag first, then header; a page flagged on both is reported once). parseLinkHeaderCanonical is now exported from canonical-header.ts instead of being written a second time.

Acceptance criteria

  • A non-home page whose canonical resolves to the root fails canonical-to-homepage as an error, showing the page URL and the canonical.
  • The home page with a self canonical is not flagged (the check emits nothing when clean, so no pass row is added to every page and no existing finding count moves).
  • Root variants (trailing slash, /index.html, www and bare host) are one root.
  • A locale home such as /en/ canonicaling to / is a warning.
  • A page that redirects to the home page is not flagged.
  • The Link header canonical is treated like the tag.
  • Every other page gets the same result as before: packages/rules/tests/core-canonical-home-1685.test.ts pins the existing canonical check (missing, relative, self, other URL, other site) and was green on the rule before the change (run against a copy of the old file).
  • docs/rules/core/canonical.mdx describes the check.

Tests: the 41 in that file; also core-canonical-form-drift, canonical-chain-redirect-evidence, rule-verdict-scope, golden-finding-messages and the canonical golden pass, and golden-baseline reports findings=103747, unchanged (its test process is being killed by the lane watchdog at 1.2 GB RSS here, so I read the pinned count from its output rather than its pass line). tsgo in packages/rules, root lint, make validate.

Note: the check only emits when flagged, so a page that stops being flagged has no row; the merge treats an absent key as resolved. The squirrelscan agent skill needs no change.

@nc9

nc9 commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Landed on main as dc55a8c, f4d8c31, a277434 (later commits there carry the review fixes). Closing this draft as superseded.

nik

@nc9 nc9 closed this Nov 11, 2026
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.

core/canonical: flag non-home pages whose canonical points at the homepage

1 participant