Skip to content

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

feat: markdown alternate tags + llms.txt cleanup (#48287)

Pamela Chia9113c2ba04ab
diff --git a/apps/www/app/(home)/page.tsx b/apps/www/app/(home)/page.tsx
index 6fd479bb6b8..cf0bf976c51 100644
--- a/apps/www/app/(home)/page.tsx
+++ b/apps/www/app/(home)/page.tsx
@@ -1,5 +1,12 @@
+import type { Metadata } from 'next'
+
import { FrameworksSection } from './_components/FrameworksSection'
import { HomeContent } from './_components/HomeContent'
+import { mdAlternates } from '@/lib/md-alternates'
+
+export const metadata: Metadata = {
+ alternates: mdAlternates('homepage'),
+}
export default function HomePage() {
return <HomeContent frameworksSlot={<FrameworksSection />} />
diff --git a/apps/www/app/(products)/auth/page.tsx b/apps/www/app/(products)/auth/page.tsx
index 92a1d7535d6..6276384f5fb 100644
--- a/apps/www/app/(products)/auth/page.tsx
+++ b/apps/www/app/(products)/auth/page.tsx
@@ -3,11 +3,13 @@ import type { Metadata } from 'next'
import { ApiSection } from './_components/ApiSection'
import { AuthContent } from './_components/AuthContent'
import { RLSSection } from './_components/RLSSection'
+import { mdAlternates } from '@/lib/md-alternates'
export const metadata: Metadata = {
title: 'Auth | Supabase',
description:
'Add user sign ups and logins to your app. Secure your data with Row Level Security. Works with all major OAuth providers.',
+ alternates: mdAlternates('auth'),
}
export default function AuthPage() {
diff --git a/apps/www/app/(products)/database/page.tsx b/apps/www/app/(products)/database/page.tsx
index f699b84f336..26971123dbe 100644
--- a/apps/www/app/(products)/database/page.tsx
+++ b/apps/www/app/(products)/database/page.tsx
@@ -2,11 +2,13 @@ import type { Metadata } from 'next'
import { ApiSection } from './_components/ApiSection'
import { DatabaseContent } from './_components/DatabaseContent'
+import { mdAlternates } from '@/lib/md-alternates'
export const metadata: Metadata = {
title: 'Database | Supabase',
description:
'Every Supabase project is a dedicated Postgres database. 100% portable with no vendor lock-in.',
+ alternates: mdAlternates('database'),
}
export default function DatabasePage() {
diff --git a/apps/www/app/(products)/edge-functions/page.tsx b/apps/www/app/(products)/edge-functions/page.tsx
index e7358b5f469..999a635f90e 100644
--- a/apps/www/app/(products)/edge-functions/page.tsx
+++ b/apps/www/app/(products)/edge-functions/page.tsx
@@ -1,10 +1,12 @@
import type { Metadata } from 'next'
import { EdgeFunctionsContent } from './_components/EdgeFunctionsContent'
+import { mdAlternates } from '@/lib/md-alternates'
export const metadata: Metadata = {
title: 'Edge Functions | Supabase',
description: 'Execute your code closest to your users with fast deploy times and low latency.',
+ alternates: mdAlternates('edge-functions'),
}
export default function EdgeFunctionsPage() {
diff --git a/apps/www/app/(products)/realtime/page.tsx b/apps/www/app/(products)/realtime/page.tsx
index d9018b99747..fa6be5958ee 100644
--- a/apps/www/app/(products)/realtime/page.tsx
+++ b/apps/www/app/(products)/realtime/page.tsx
@@ -2,11 +2,13 @@ import type { Metadata } from 'next'
import { ApiSection } from './_components/ApiSection'
import { RealtimeContent } from './_components/RealtimeContent'
+import { mdAlternates } from '@/lib/md-alternates'
export const metadata: Metadata = {
title: 'Realtime | Supabase',
description:
'Sync client state globally over WebSockets. Listen to database changes, store user presence, and broadcast messages in real time.',
+ alternates: mdAlternates('realtime'),
}
export default function RealtimePage() {
diff --git a/apps/www/app/(products)/storage/page.tsx b/apps/www/app/(products)/storage/page.tsx
index 736e585dcfb..484c72b9707 100644
--- a/apps/www/app/(products)/storage/page.tsx
+++ b/apps/www/app/(products)/storage/page.tsx
@@ -3,11 +3,13 @@ import type { Metadata } from 'next'
import { ApiSection } from './_components/ApiSection'
import { PermissionsSection } from './_components/PermissionsSection'
import { StorageContent } from './_components/StorageContent'
+import { mdAlternates } from '@/lib/md-alternates'
export const metadata: Metadata = {
title: 'Storage | Supabase',
description:
'An open source S3 compatible storage solution with unlimited scalability, for any file type.',
+ alternates: mdAlternates('storage'),
}
export default function StoragePage() {
diff --git a/apps/www/app/blog/[slug]/page.tsx b/apps/www/app/blog/[slug]/page.tsx
index e8cb8e50d2b..510218781f9 100644
--- a/apps/www/app/blog/[slug]/page.tsx
+++ b/apps/www/app/blog/[slug]/page.tsx
@@ -12,6 +12,7 @@ import {
import { breadcrumbs } from '@/lib/breadcrumbs'
import { SITE_ORIGIN } from '@/lib/constants'
import { blogPostingSchema, breadcrumbListSchema, serializeJsonLd } from '@/lib/json-ld'
+import { mdAlternates } from '@/lib/md-alternates'
import { getAllPostSlugs, getPostdata, getSortedPosts } from '@/lib/posts'
import type { Blog, BlogData, PostReturnType } from '@/types/post'
@@ -71,11 +72,7 @@ export async function generateMetadata({ params }: { params: Promise<Params> }):
return {
title: blogPost.title,
description: blogPost.description,
- alternates: {
- types: {
- 'text/markdown': `/blog/${slug}.md`,
- },
- },
+ alternates: mdAlternates(`blog/${slug}`),
openGraph: {
title: blogPost.title,
description: blogPost.description,
diff --git a/apps/www/app/llms-full.txt/route.ts b/apps/www/app/llms-full.txt/route.ts
index a243474bbe6..3e6931ec9ae 100644
--- a/apps/www/app/llms-full.txt/route.ts
+++ b/apps/www/app/llms-full.txt/route.ts
@@ -2,7 +2,6 @@ import { promises as fs } from 'node:fs'
import path from 'node:path'
import { isFeatureEnabled } from 'common/enabled-features'
-import { MD_CONTENT } from '@/app/api-v2/md/content.generated'
import { generatePricingContent } from '@/lib/llms'
export const dynamic = 'force-dynamic'
@@ -53,15 +52,6 @@ async function readAllGuideMarkdown(): Promise<string> {
return contents.join('\n\n---\n\n')
}
-// Order is set by scripts/generateMdContent.mjs (homepage first, rest
-// alphabetical). pricing is appended here since it's dynamic.
-async function readProductOverviews(): Promise<string> {
- const staticContents = [...MD_CONTENT.values()]
- const pricingContent = generatePricingContent()
-
- return [...staticContents, pricingContent].join('\n\n---\n\n')
-}
-
async function fetchSourceContent(slug: string): Promise<string | null> {
const docsUrl = process.env.NEXT_PUBLIC_DOCS_URL
if (!docsUrl) return null
@@ -76,8 +66,9 @@ export async function GET() {
const sources = getSources()
const enabledSources = sources.filter((source) => source.enabled)
- const [productContent, guidesContent, ...sourceContents] = await Promise.all([
- readProductOverviews(),
+ const pricingContent = generatePricingContent()
+
+ const [guidesContent, ...sourceContents] = await Promise.all([
readAllGuideMarkdown(),
...enabledSources.map(async (source) => {
const text = await fetchSourceContent(source.slug)
@@ -97,9 +88,9 @@ export async function GET() {
const content = [
'# Supabase',
'',
- '## Product Overview',
+ '## Pricing',
'',
- productContent,
+ pricingContent,
'',
'---',
'',
diff --git a/apps/www/app/llms.txt/route.ts b/apps/www/app/llms.txt/route.ts
index 4c07a6d7fd8..230a36ddf04 100644
--- a/apps/www/app/llms.txt/route.ts
+++ b/apps/www/app/llms.txt/route.ts
@@ -73,23 +73,6 @@ async function getSources(): Promise<Source[]> {
]
}
-// Editorial ordering for the product overview list (mirrors the homepage
-// products section); not derived from MD_PAGES because the order is
-// intentional. When dropping a new content/md/<slug>.md file, add a matching
-// entry here too — otherwise the page ships but won't be linked from /llms.txt.
-const PRODUCT_OVERVIEW_LINKS = [
- '- [Supabase Overview](https://supabase.com/homepage.md)',
- '- [Supabase Database](https://supabase.com/database.md)',
- '- [Supabase Auth](https://supabase.com/auth.md)',
- '- [Supabase Storage](https://supabase.com/storage.md)',
- '- [Supabase Edge Functions](https://supabase.com/edge-functions.md)',
- '- [Supabase Realtime](https://supabase.com/realtime.md)',
- '- [Supabase Vector](https://supabase.com/vector.md)',
- '- [Supabase Cron](https://supabase.com/modules/cron.md)',
- '- [Supabase Queues](https://supabase.com/modules/queues.md)',
- '- [Supabase Pricing](https://supabase.com/pricing.md)',
-].join('\n')
-
export async function GET() {
const sources = await getSources()
@@ -107,9 +90,9 @@ export async function GET() {
'',
sourceLinks,
'',
- '## Product Overview',
+ '## Pricing',
'',
- PRODUCT_OVERVIEW_LINKS,
+ '- [Supabase Pricing](https://supabase.com/pricing.md)',
].join('\n')
return new Response(content, {
diff --git a/apps/www/app/pricing/page.tsx b/apps/www/app/pricing/page.tsx
index cf07c6aead0..cc7d693a86d 100644
--- a/apps/www/app/pricing/page.tsx
+++ b/apps/www/app/pricing/page.tsx
@@ -3,16 +3,13 @@ import type { Metadata } from 'next'
import PricingContent from './PricingContent'
import { breadcrumbs } from '@/lib/breadcrumbs'
import { breadcrumbListSchema, serializeJsonLd } from '@/lib/json-ld'
+import { mdAlternates } from '@/lib/md-alternates'
export const metadata: Metadata = {
title: 'Pricing & Fees | Supabase',
description:
'Explore Supabase fees and pricing information. Find our competitive pricing Plans, with no hidden pricing. We have a generous Free Plan for those getting started, and Pay As You Go for those scaling up.',
- alternates: {
- types: {
- 'text/markdown': '/pricing.md',
- },
- },
+ alternates: mdAlternates('pricing'),
openGraph: {
title: 'Pricing & Fees | Supabase',
description:
diff --git a/apps/www/content/md/vector.md b/apps/www/content/md/modules/vector.md
similarity index 100%
rename from apps/www/content/md/vector.md
rename to apps/www/content/md/modules/vector.md
diff --git a/apps/www/lib/md-alternates.ts b/apps/www/lib/md-alternates.ts
new file mode 100644
index 00000000000..6f651491734
--- /dev/null
+++ b/apps/www/lib/md-alternates.ts
@@ -0,0 +1,11 @@
+import type { Metadata } from 'next'
+
+import { SITE_ORIGIN } from './constants'
+
+export function mdAlternates(slug: string): Metadata['alternates'] {
+ return {
+ types: {
+ 'text/markdown': `${SITE_ORIGIN}/${slug}.md`,
+ },
+ }
+}
diff --git a/apps/www/lib/redirects.js b/apps/www/lib/redirects.js
index ef9162f9e5e..b4e6ba6618a 100644
--- a/apps/www/lib/redirects.js
+++ b/apps/www/lib/redirects.js
@@ -3314,6 +3314,7 @@ module.exports = [
{ permanent: true, source: '/llms/edge-functions.txt', destination: '/edge-functions.md' },
{ permanent: true, source: '/llms/realtime.txt', destination: '/realtime.md' },
{ permanent: true, source: '/llms/storage.txt', destination: '/storage.md' },
- { permanent: true, source: '/llms/vector.txt', destination: '/vector.md' },
+ { permanent: true, source: '/llms/vector.txt', destination: '/modules/vector.md' },
{ permanent: true, source: '/llms/pricing.txt', destination: '/pricing.md' },
+ { permanent: true, source: '/vector.md', destination: '/modules/vector.md' },
]
diff --git a/apps/www/md-alternates.test.ts b/apps/www/md-alternates.test.ts
new file mode 100644
index 00000000000..707d7d7df89
--- /dev/null
+++ b/apps/www/md-alternates.test.ts
@@ -0,0 +1,109 @@
+import { existsSync, promises as fs } from 'node:fs'
+import path from 'node:path'
+import { describe, expect, it } from 'vitest'
+
+import { SITE_ORIGIN } from './lib/constants'
+import { mdAlternates } from './lib/md-alternates'
+
+const DYNAMIC_SLUGS = ['pricing']
+
+const MDX_SECTIONS = ['blog', 'customers', 'events']
+
+async function collectContentMdSlugs(dir: string, prefix = ''): Promise<string[]> {
+ const dirents = await fs.readdir(dir, { withFileTypes: true })
+ const slugs: string[] = []
+ for (const dirent of dirents) {
+ const slug = prefix ? `${prefix}/${dirent.name}` : dirent.name
+ if (dirent.isDirectory()) {
+ slugs.push(...(await collectContentMdSlugs(path.join(dir, dirent.name), slug)))
+ } else if (dirent.name.endsWith('.md')) {
+ slugs.push(slug.replace(/\.md$/, ''))
+ }
+ }
+ return slugs
+}
+
+async function collectAppRouterPages(
+ dir: string,
+ segments: string[] = []
+): Promise<Map<string, string>> {
+ const pages = new Map<string, string>()
+ const dirents = await fs.readdir(dir, { withFileTypes: true })
+ for (const dirent of dirents) {
+ if (dirent.isDirectory()) {
+ if (dirent.name.startsWith('[') || dirent.name.startsWith('_')) continue
+ const nextSegments = dirent.name.startsWith('(') ? segments : [...segments, dirent.name]
+ const nested = await collectAppRouterPages(path.join(dir, dirent.name), nextSegments)
+ nested.forEach((filePath, slug) => pages.set(slug, filePath))
+ } else if (dirent.name === 'page.tsx') {
+ pages.set(segments.join('/') || 'homepage', path.join(dir, dirent.name))
+ }
+ }
+ return pages
+}
+
+describe('mdAlternates', () => {
+ it('emits the absolute .md sibling URL', () => {
+ expect(mdAlternates('auth')).toEqual({
+ types: { 'text/markdown': `${SITE_ORIGIN}/auth.md` },
+ })
+ expect(mdAlternates('modules/vector')).toEqual({
+ types: { 'text/markdown': `${SITE_ORIGIN}/modules/vector.md` },
+ })
+ })
+})
+
+describe('markdown alternate drift', () => {
+ it('every markdown-served slug has a page advertising its .md sibling', async () => {
+ const contentSlugs = await collectContentMdSlugs(path.join(process.cwd(), 'content/md'))
+ const expectedSlugs = [...contentSlugs, ...DYNAMIC_SLUGS]
+ const appPages = await collectAppRouterPages(path.join(process.cwd(), 'app'))
+
+ expect(contentSlugs.length).toBeGreaterThan(0)
+
+ for (const slug of expectedSlugs) {
+ const appPagePath = appPages.get(slug)
+ if (appPagePath) {
+ const source = await fs.readFile(appPagePath, 'utf-8')
+ expect(
+ source.includes(`alternates: mdAlternates('${slug}')`),
+ `${path.relative(process.cwd(), appPagePath)} must contain "alternates: mdAlternates('${slug}')" in its metadata export`
+ ).toBe(true)
+ } else {
+ expect(
+ existsSync(path.join(process.cwd(), 'pages', `${slug}.tsx`)),
+ `no page found for markdown slug "${slug}" — App Router pages need mdAlternates, Pages Router pages are covered by _app.tsx`
+ ).toBe(true)
+ }
+ }
+ })
+
+ it('pages/_app.tsx advertises the .md sibling for Pages Router pages', async () => {
+ const source = await fs.readFile(path.join(process.cwd(), 'pages', '_app.tsx'), 'utf-8')
+ expect(
+ source.includes('MD_PAGES.has('),
+ 'pages/_app.tsx must gate the markdown alternate on MD_PAGES membership'
+ ).toBe(true)
+ expect(
+ source.includes('rel="alternate" type="text/markdown"'),
+ 'pages/_app.tsx must render the text/markdown alternate link for markdown-served slugs'
+ ).toBe(true)
+ })
+
+ it.for(MDX_SECTIONS)('%s pages advertise their .md sibling', async (urlPrefix) => {
+ const appPagePath = path.join(process.cwd(), 'app', urlPrefix, '[slug]', 'page.tsx')
+ if (!existsSync(appPagePath)) {
+ expect(
+ existsSync(path.join(process.cwd(), 'pages', urlPrefix)),
+ `section "${urlPrefix}" has neither app/${urlPrefix}/[slug]/page.tsx nor pages/${urlPrefix}/`
+ ).toBe(true)
+ return
+ }
+ const source = await fs.readFile(appPagePath, 'utf-8')
+ const wiring = 'alternates: mdAlternates(`' + urlPrefix + '/${slug}`)'
+ expect(
+ source.includes(wiring),
+ `app/${urlPrefix}/[slug]/page.tsx must contain "${wiring}" in its generateMetadata`
+ ).toBe(true)
+ })
+})