diff --git a/apps/website/src/config/llms-txt.test.ts b/apps/website/src/config/llms-txt.test.ts index d44afe7fb1f..66baa6c33d2 100644 --- a/apps/website/src/config/llms-txt.test.ts +++ b/apps/website/src/config/llms-txt.test.ts @@ -17,12 +17,16 @@ import { modelsBuildRoutes } from '../integrations/workshop-release-gate' const websiteRoot = join(dirname(fileURLToPath(import.meta.url)), '..', '..') const llmsTxt = readFileSync(join(websiteRoot, 'public', 'llms.txt'), 'utf8') const pagesDir = join(websiteRoot, 'src', 'pages') +// A redirect that only adds the trailing slash (`/models` → `/models/`) does +// not retire its source; the page is the destination, which llms.txt links. const vercelRedirectSources = new Set( ( JSON.parse(readFileSync(join(websiteRoot, 'vercel.json'), 'utf8')) as { - redirects: { source: string }[] + redirects: { source: string; destination: string }[] } - ).redirects.map((redirect) => normalizePath(redirect.source)) + ).redirects + .filter((redirect) => redirect.destination !== `${redirect.source}/`) + .map((redirect) => normalizePath(redirect.source)) ) /** diff --git a/apps/website/src/config/redirects.test.ts b/apps/website/src/config/redirects.test.ts index 8460e205f06..70d0e0b15eb 100644 --- a/apps/website/src/config/redirects.test.ts +++ b/apps/website/src/config/redirects.test.ts @@ -93,6 +93,33 @@ describe('astro redirect destinations', () => { }) }) +/** + * The catalogue was reachable at both `/models` and `/models/`, each a 200, + * and search traffic split between them (only the slash form ranked). Every + * page canonicalizes with the slash, so the hosting layer sends the other + * form there permanently. + */ +describe('Models trailing-slash redirects', () => { + it.for(['/models', '/zh-CN/models'])( + 'sends %s to its trailing-slash form permanently', + (source) => { + const redirect = findRedirect(source) + + if (!redirect) { + throw new Error(`${source} is missing from vercel.json`) + } + + expect(redirect.destination).toBe(`${source}/`) + expect(redirect.permanent).toBe(true) + } + ) + + it('leaves the canonical Models routes unredirected', () => { + expect(findRedirect('/models/')).toBeUndefined() + expect(findRedirect('/zh-CN/models/')).toBeUndefined() + }) +}) + describe('legacy Enterprise redirects', () => { it.for([ '/cloud/enterprise', diff --git a/apps/website/vercel.json b/apps/website/vercel.json index 6bbb347ed5b..eae9c8d7076 100644 --- a/apps/website/vercel.json +++ b/apps/website/vercel.json @@ -52,6 +52,16 @@ } ], "redirects": [ + { + "source": "/models", + "destination": "/models/", + "permanent": true + }, + { + "source": "/zh-CN/models", + "destination": "/zh-CN/models/", + "permanent": true + }, { "source": "/career", "destination": "/careers",