Files
supabase/apps/docs/internals
Ivan VasilovandClaude Sonnet 5.5 397cc79fdb fix(docs): generate sitemap before next build (#52110)
## Problem

`/docs/sitemap.xml` returns a 404 after the Next.js 16 upgrade (#52045).
Resolves
[FE-4704](https://linear.app/supabase/issue/FE-4704/fix-missing-sitemapxml-on-the-docs-site).

The sitemap is written to `public/sitemap.xml` by `pnpm run
build:sitemap`, which ran in `postbuild`, after `next build` had
finished. On a preview deployment built that way, the file was deployed
but only served at `/sitemap.xml`, not under the `/docs` base path.
`public/` files that exist at build time, like `robots.txt`, are served
at both `/robots.txt` and `/docs/robots.txt`.

The Next.js docs say only files in `public/` at build time are served
([static assets,
v14](https://nextjs.org/docs/14/app/building-your-application/optimizing/static-assets):
"Only assets that are in the `public` directory at build time will be
served by Next.js"). The current docs no longer include that note, and
nothing I found says Next.js 16 changed this behavior. The likely cause
is that Vercel maps build-time `public/` files under the base path,
while files added afterward are only served as plain static files at the
root. I couldn't confirm this, or why it worked before the Next.js 16
upgrade.

## Solution

Run `build:sitemap` at the end of `prebuild`, so `public/sitemap.xml`
exists before `next build`. The generator only reads source content and
the references codegen output, which `prebuild` already produces
earlier. `postbuild` now only runs the static assets upload.

The generator also sorts entries by link, so the sitemap order is stable
across builds.

## How to test

Check `/docs/sitemap.xml` on the preview deployment. It returns 200 with
the same set of URLs as the sitemap currently served in production.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-22 00:00:46 +02:00
..