Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix(www): include app routes in sitemap (#50277)

Pamela Chia5e8e551e2c05
diff --git a/apps/www/generate-sitemap.test.ts b/apps/www/generate-sitemap.test.ts
index 7778886cf17..42be8704b6d 100644
--- a/apps/www/generate-sitemap.test.ts
+++ b/apps/www/generate-sitemap.test.ts
@@ -189,6 +189,46 @@ describe('generate-sitemap lastmod', () => {
})
})
+describe('generate-sitemap App Router pages', () => {
+ it.each(['app/page.tsx', 'app/(home)/page.tsx'])(
+ 'includes only static page URLs without lastmod, with homepage at %s',
+ (homepage) => {
+ const dir = writeFixture({
+ [homepage]: '',
+ 'app/(group)/example/page.tsx': '',
+ 'app/(marketing)/guides/(topics)/start/page.tsx': '',
+ 'app/blog/example/page.tsx': '',
+ 'app/events/example/page.tsx': '',
+ 'app/reference/index/page.tsx': '',
+ 'app/things/[slug]/page.tsx': '',
+ 'app/things/[slug]/details/page.tsx': '',
+ 'app/(group)/[...slug]/page.tsx': '',
+ 'app/optional/[[...slug]]/page.tsx': '',
+ 'app/example/layout.tsx': '',
+ 'app/api/route.ts': '',
+ 'app/loading.tsx': '',
+ 'pages/company.tsx': '',
+ })
+ const result = runGenerator(dir)
+ expect(result.status, result.stderr).toBe(0)
+ const entries = urlEntries(fs.readFileSync(path.join(dir, 'public/sitemap_www.xml'), 'utf-8'))
+ expect(entries.sort((a, b) => a.loc.localeCompare(b.loc))).toEqual(
+ [
+ '',
+ '/blog/example',
+ '/company',
+ '/evals',
+ '/events/example',
+ '/example',
+ '/guides/start',
+ '/reference/index',
+ ].map((route) => ({ loc: `https://supabase.com${route}`, lastmod: undefined }))
+ )
+ },
+ SPAWN_TIMEOUT_MS
+ )
+})
+
describe('frontmatter dates in sitemap and blog JSON-LD', () => {
it.each([
['2026-01-14T09:30:00', '2026-01-14'],
diff --git a/apps/www/internals/generate-sitemap.mjs b/apps/www/internals/generate-sitemap.mjs
index 2a879479f1c..0f64bfca847 100644
--- a/apps/www/internals/generate-sitemap.mjs
+++ b/apps/www/internals/generate-sitemap.mjs
@@ -65,6 +65,7 @@ async function generate() {
'pages/*.tsx',
'pages/*.mdx',
'pages/**/*.tsx',
+ 'app/**/page.tsx',
'_blog/*.mdx',
'_case-studies/*.mdx',
'_customers/*.mdx',
@@ -90,6 +91,13 @@ async function generate() {
// Generate URLs for static pages
const staticUrls = pages
.map((page) => {
+ if (page.startsWith('app/')) {
+ const segments = page.split('/').slice(1, -1)
+ if (segments.some((segment) => segment.includes('['))) return null
+ const path = segments.filter((segment) => !/^\(.*\)$/.test(segment)).join('/')
+ return urlEntry(`https://supabase.com${path ? `/${path}` : ''}`)
+ }
+
const path = page
.replace('.next/server/pages', '')
.replace(/^pages/, '')