Repository navigation
Conversation
…e home page #1685 Signed-off-by: Nik Cubrilovic <[email protected]>
…and default.* as home spellings #1685 Signed-off-by: Nik Cubrilovic <[email protected]>
…t> as home spellings #1685 Signed-off-by: Nik Cubrilovic <[email protected]>
Contributor
Author
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.
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/canonicalpassed it. A newcanonical-to-homepagecheck, emitted only when a page is flagged, catches it. The logic is one pure function,homepageCanonicalVerdict(pageUrl, canonical), returningerror,locale-homeornone, with a table test.error(check statusfail): a page that is not the home page canonicals to the site root. The message names the page URL and the canonical;detailscarrypageUrl,canonicalandsource(tagorheader).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=5is 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)./index.html, thewwwand bare form of the host, http or https, and a fragment is ignored.Linkheader canonical is read like the tag (tag first, then header; a page flagged on both is reported once).parseLinkHeaderCanonicalis now exported fromcanonical-header.tsinstead of being written a second time.Acceptance criteria
canonical-to-homepageas an error, showing the page URL and the canonical./index.html, www and bare host) are one root./en/canonicaling to/is a warning.Linkheader canonical is treated like the tag.packages/rules/tests/core-canonical-home-1685.test.tspins the existingcanonicalcheck (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.mdxdescribes 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, andgolden-baselinereports 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).tsgoinpackages/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.