Back to Workshop resources
SEO · AEO · GEO1 min read
Sitemap.xml in Next.js — generate programmatically.
Use app/sitemap.ts to generate /sitemap.xml from your real routes. Auto-updates on every build.
Overview
A sitemap tells Google + AI crawlers what pages your site has and how often they update. Next.js generates it from a TypeScript file — no plugin needed.
The file
Create
src/app/sitemap.ts exporting a default function that returns a MetadataRoute.Sitemap (array of {url, lastModified, changeFrequency, priority}).Include dynamic routes
Map over your blog posts, articles, courses, etc. to add their URLs to the sitemap automatically.
Exclude what shouldn't be indexed
Don't include /preview/ if it's gated or noindex. Don't include /admin or password-protected routes.
PreviousBing Webmaster Tools for Singapore — why it matters.Next Getting cited by Perplexity — what we know in 2026.
Want to Apply This to Your Business?
We're a Singapore AI development and automation agency. Let's discuss how we can help solve your specific challenges.