Skip to content

sitemap.ts or sitemap.xml missing (App Router)

No app/sitemap.ts and no public/sitemap.xml. Search engines rely on crawl discovery alone. Newly published pages can take weeks to be indexed, and pages with no inbound links may never appear in search results.

Create app/sitemap.ts. Next.js generates and serves the sitemap at /sitemap.xml automatically.

app/sitemap.ts
import type { MetadataRoute } from 'next'
export default function sitemap(): MetadataRoute.Sitemap {
return [
{
url: 'https://example.com',
lastModified: new Date(),
changeFrequency: 'monthly',
priority: 1,
},
{
url: 'https://example.com/about',
lastModified: new Date(),
changeFrequency: 'yearly',
priority: 0.8,
},
]
}

For sites with many dynamic pages, fetch from your CMS or database inside sitemap().

app/sitemap.ts
import type { MetadataRoute } from 'next'
export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const posts = await getPosts()
return [
{ url: 'https://example.com', lastModified: new Date() },
...posts.map(post => ({
url: `https://example.com/blog/${post.slug}`,
lastModified: post.updatedAt,
})),
]
}
Terminal window
curl https://yourdomain.com/sitemap.xml

Confirm the response is valid XML with <urlset> as the root element and lists your pages. Then re-run orino audit.