Skip to content

Fix /teams/team-ben by keeping the /teams wildcard on the [slug] page - #20057

Open
benben wants to merge 2 commits into
masterfrom
posthog/fix-team-ben-route
Open

Fix /teams/team-ben by keeping the /teams wildcard on the [slug] page#20057
benben wants to merge 2 commits into
masterfrom
posthog/fix-team-ben-route

Conversation

@benben

@benben benben commented Sep 10, 2026

Copy link
Copy Markdown
Member

Changes

/teams/team-ben served the correct page, then replaced it with an error a moment later.

onCreatePage in gatsby-node.ts gave the /teams/* match path to every page under /teams/, so the static team-ben page and the client-only [slug] page both claimed the same wildcard. [slug] comes first in match-paths.json, and @gatsbyjs/reach-router breaks a tie in scores by array order, so [slug] won every /teams URL. On hydration the browser threw away the server-rendered Ben page, loaded [slug], looked up a team with the slug team-ben, found none, and showed the error.

Why: the page is unreachable, and any future static page under /teams/ would break the same way.

The fix gives the wildcard to the [slug] page only. Gatsby then adds an exact match path for each static page under /teams/ (see getMatchPaths in requires-writer), and an exact path outranks a splat, so the static page wins. This is how /teams, /teams/new, and /community/profiles/me already work. It also removes the need for the /teams/new exception, so that exception is gone.

Evidence from the live bundle, before the fix:

{ "path": "/teams/new",       "matchPath": "/teams/new" }
{ "path": "/teams",           "matchPath": "/teams" }
{ "path": "/teams/[slug]",    "matchPath": "/teams/*" }   <- wins the tie
{ "path": "/teams/team-ben",  "matchPath": "/teams/*" }

No visual change: the Ben page markup is untouched, and the server-rendered HTML of the broken page already shows it in full. Please confirm on the preview build that /teams/team-ben stays on screen and that other team pages still route.

I could not install dependencies in my environment, so pnpm start and a production build did not run here. prettier reports no change to the diff.

Checklist

  • I've read the docs and/or content style guides.
  • Words are spelled using American English
  • Use relative URLs for internal links
  • I've checked the pages added or changed in the Vercel preview build
  • If I moved a page, I added a redirect in vercel.json (no page moved)

Created with PostHog from a Slack thread

onCreatePage gave the /teams/* match path to every page under /teams/, so the
static team-ben page and the [slug] page both claimed the same wildcard. The
[slug] page comes first in match-paths.json, so it won the tie for every /teams
URL. The browser replaced the server-rendered team-ben page with [slug], which
looked up a team with the slug "team-ben", found none, and showed an error.

Give the wildcard to the [slug] page only. Gatsby then adds an exact match path
for each static page under /teams/, which outranks the wildcard.

Generated-By: PostHog Desktop
Task-Id: 7a61ba1d-a58f-4f48-8af1-a64ceea893c2
@benben benben self-assigned this Sep 10, 2026
@github-actions github-actions Bot added the website About the website (beyond just landing pages) label Sep 10, 2026
@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Deploy preview

Status Details Updated (UTC)
🟢 Ready View preview Sep 10, 2026 09:36AM

@benben
benben marked this pull request as ready for review September 10, 2026 07:28
@benben
benben requested a review from a team as a code owner September 10, 2026 07:28
@benben
benben enabled auto-merge (squash) September 10, 2026 07:29
@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Bundle report

Total JS (gzip)

8.86 MiB (+0.0 KiB / +0.0%)

Eager graph (modules shipped in each entrypoint's initial chunks)

Entrypoint Eager size Budget Modules
app 18.47 MiB (+0.7 KiB / +0.0%) report-only 2054
Largest modules in the app closure
Module Size
./src/data/mcp-tools.json 1119.8 KiB
css ./node_modules/.pnpm/css-loader@5.2.7_webpack@5.101.3/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[8].oneOf[1].use[1]!./node_modules/.pnpm/postcss-loader@4.3.0_postcss@8.5.6_webpack@5.101.3/node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[8].oneOf[1].use[2]!./src/styles/global.css 761.0 KiB
./src/components/Stickers/Stickers.tsx 696.4 KiB
./node_modules/.pnpm/@radix-ui+react-icons@1.3.2_react@18.3.1/node_modules/@radix-ui/react-icons/dist/react-icons.esm.js 481.4 KiB
./node_modules/.pnpm/@posthog+brand@0.8.0_react@18.3.1/node_modules/@posthog/brand/dist/generated/hoggies/svg/x-ray.mjs 480.8 KiB
./node_modules/.pnpm/rehype-raw@7.0.0/node_modules/rehype-raw/lib/index.js + 29 modules 395.1 KiB
./node_modules/.pnpm/@posthog+brand@0.8.0_react@18.3.1/node_modules/@posthog/brand/dist/generated/hoggies/svg/im-the-driver.mjs 385.7 KiB
./src/hooks/useCustomers.tsx + 55 modules 370.0 KiB
./node_modules/.pnpm/@posthog+icons@0.36.6_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@posthog/icons/dist/posthog-icons.es.js 354.8 KiB
./node_modules/.pnpm/react-markdown@8.0.7_@types+react@16.14.66_react@18.3.1/node_modules/react-markdown/lib/react-markdown.js + 88 modules 351.4 KiB
./src/components/ProductComparisonTable/index.tsx + 126 modules 302.5 KiB
./node_modules/.pnpm/cloudinary-core@2.14.0_lodash@4.17.21/node_modules/cloudinary-core/cloudinary-core.js 281.9 KiB
./node_modules/.pnpm/@posthog+brand@0.8.0_react@18.3.1/node_modules/@posthog/brand/dist/generated/hoggies/svg/doll-house.mjs 281.7 KiB
./node_modules/.pnpm/@posthog+brand@0.8.0_react@18.3.1/node_modules/@posthog/brand/dist/generated/hoggies/svg/director.mjs 275.6 KiB
./src/components/SearchUI/index.tsx + 87 modules 273.7 KiB

Eager-graph budgets are report-only until a baseline is established. Sizes are gzip of public/**/*.js; eager size is webpack module source bytes for the modules actually shipped in the entrypoint's initial chunks (post-tree-shake).

@benjackwhite benjackwhite left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

doing gods work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

website About the website (beyond just landing pages)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants