Repository navigation
fix(sitemap): list only self-canonical URLs - #2569
Open
NopeCharon wants to merge 1 commit into
Open
NopeCharon wants to merge 1 commit into
NopeCharon wants to merge 1 commit into
Conversation
The sitemap filter removed redirect stubs but kept pages whose rel="canonical" points elsewhere: /en/ (served at /), unversioned copies of default-version docs and API pages, and other locales' copies of the untranslated blog and API pages. Those made up 635 of the 1,311 URLs in the published sitemap, contradicting the canonical tags on the pages. Move the filter to src/utils/sitemap.mjs so it can be unit tested, and make it follow the same rules as Layout.astro and [...slug].astro. The versioned sections and "global" pages come from the link-localization core, so a page marked global in the menu stays listed without further configuration. Fixes expressjs#2568 Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
✅ Deploy Preview for expressjscom-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This branch has not been deployed
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.

Fixes #2568
The sitemap lists 635 URLs whose
rel="canonical"points to a different page. The filter now drops them, so the sitemap matches what the pages declare:/en/, because the English homepage is served at//es/guide/routing//es/5x/api/express/"Global" pages such as
/es/guide/migrating-5/only exist unversioned, so they stay listed. Redirect stubs are still excluded as before.The filter moved from
astro.config.mjstosrc/utils/sitemap.mjsso it can be unit tested. It reuses the versioned sections and global pages fromrewrite-localized-links-core.mjs, which now exports them.Validation
tests/unit/sitemap.test.mjs. One test checks every file in thepagescollection, so a new page that isn't markedglobalin the menu fails instead of silently leaving the sitemap.npm run test:unitpasses, and Prettier and ESLint pass on the changed files.rel="canonical". It keeps 676 and drops 635. No kept page points elsewhere, and no dropped page is its own canonical.