Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions apps/website/src/config/llms-txt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>(
(
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))
)

/**
Expand Down
27 changes: 27 additions & 0 deletions apps/website/src/config/redirects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
10 changes: 10 additions & 0 deletions apps/website/vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@
}
],
"redirects": [
{
"source": "/models",
"destination": "/models/",
"permanent": true
},
Comment on lines +55 to +59

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking): with #18480 in, the 148 model pages carry 887 links to bare /models or /models?…, all built from workshop: '/models' in config/routes.ts:52: the "Back to all models" link, "Browse all models", and every tag and use-case filter link (/models?q=flux, /models?useCase=generate-images). After this lands, each one is a redirect hop on pages we're asking Google to crawl. Could that constant become '/models/' in this PR, so the redirect only ever catches outside links?

{
"source": "/zh-CN/models",
"destination": "/zh-CN/models/",
"permanent": true
},
{
"source": "/career",
"destination": "/careers",
Expand Down
Loading