test: redirect check on a PR that breaks redirects - #1896
marcleblanc2 wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
✅ The redirects an earlier revision of this PR broke are fixed |
✅ The broken links an earlier revision of this PR introduced are fixed |
e9053b8 to
878abd1
Compare
❌ This PR breaks 8 redirect(s)Redirects are used so inbound traffic from external sources (links inside old versions of our product, bookmarks, search results, etc.) to old doc pages still reaches a relevant page. A correct entry maps the old page path, exactly as the browser requests it, straight to a page that exists today, with an optional #heading that exists on the destination page: {
source: '/old/section/page',
destination: '/new/section/page#heading-slug'
},Each section below explains how to fix the entries listed under it. Do not use redirects for broken internal links, internal links must be fixed properly to tame the tech debt snowball no one wants to deal with; the "Check links" PR check comment lists the links this PR broke, if any. Source overshadows a docs page that existsRedirects take precedence over pages, so visitors to that page's URL are redirected away from it. Update or remove the redirect or the page to remove the conflict.
Source has a #fragment, so this redirect can never matchUse the page path alone as the source. #fragments are processed in the browser, so browsers never send them to web servers. If the redirect destination has a #fragment, it takes precedence, otherwise if the customer clicked a link which has a #fragment, it'll be kept and tried on the destination page.
Source or destination starts with /docsWrite paths without the /docs prefix. The site removes /docs from the requested URL before matching sources, and adds it back in front of the destination, so a /docs/... source never matches and a /docs/... destination lands on /docs/docs/....
Source already has an earlier entry, so this one is never usedOnly the first entry for a source matches. Update that entry instead of adding another.
Destination is another redirectChained redirects cost the customer's browser a round trip, slow down their page load time, and frustrate them. They also make the redirects file impossible to maintain, and make it too easy to create redirect loops. Change the rule's destination to the final destination.
Destination page does not existSet the redirect destination to the page that replaced it, or remove the rule if there is no replacement page; visitors then get our fancy 404 page, with links they can click to find where they're trying to go, and the search bar.
Destination heading does not existUse the heading's correct anchor, or drop the #fragment to land the customer at the top of the page.
Reproduce locally with |
532af70 to
182a7ae
Compare
182a7ae to
165696e
Compare
165696e to
bda385d
Compare
bda385d to
3a37df1
Compare
3a37df1 to
8f1c7c0
Compare
…, duplicate, chain, missing page, missing heading) Amp-Thread-ID: https://ampcode.com/threads/T-01a088d9-b8fd-76fd-ba93-3a416c5829a3 Co-authored-by: Amp <amp@ampcode.com>
8f1c7c0 to
e1cddaf
Compare
Linear [FE-499: Fix doc site issues](https://linear.app/sourcegraph/issue/FE-499/fix-doc-site-issues) ## Problem - `src/data/redirects.ts` has ~900 entries that don't work: destination pages that no longer exist, `#fragments` in the source (browsers never send them, so the entry can never match), duplicates of an earlier source, chains to other redirects, `/docs/` prefixes - Nothing checks the file, so PRs keep adding broken redirects, and PRs that move a page or rename a heading silently break the redirects pointing at it ## Solution - `dev/check-redirects.mjs` validates every entry against the pages and headings in `docs/` - "Check redirects" PR check runs the script on the PR head and its merge base, and reports only what the PR introduced; the ~900 pre-existing problems are ignored - Runs in parallel with "Check links" - The comment groups findings by problem, and each section says how to fix its entries, so authors learn how to write a correct redirect: - Source overshadows a docs page that exists - Source has a `#fragment`, so this redirect can never match - Source or destination starts with `/docs` - Source already has an earlier entry, so this one is never used - Destination is another redirect (shows the final destination) - Destination page does not exist - Destination heading does not exist - Line numbers link to the entry in `redirects.ts` on the PR branch - The comment is created / updated in place, and once the PR is fixed, the PR check passes and the comment is updated to say so - A PR that never broke anything gets no comment - `pnpm check-redirects` runs it locally ## Verification PR check comment in test PR: #1896 (comment) <img width="1000" alt="Check redirects PR comment listing 8 broken redirects grouped by problem" src="https://ampcode.com/user-content/artifacts/a074bef7c771368ba56da54a9e62f9a41cef9402a064594646cd3e8b0fa6c166-file.png" /> ## Related - #1858 added the "Check links" PR check this is built on; #1916 added `dev/sync-review-comments.sh`, which this check calls ## Amp threads - [Redirect list cleanup](https://ampcode.com/threads/T-01a07e6f-db41-74af-bbeb-f8952e637289) - [Redirect check PR comment](https://ampcode.com/threads/T-01a088d9-b8fd-76fd-ba93-3a416c5829a3) --------- Co-authored-by: Amp <amp@ampcode.com>
Throwaway PR to exercise the Redirect check workflow from #1880. Do not merge.