Back to Blog
November 5, 2025 1 min read

Next.js SEO: robots.ts, sitemap.ts, and Metadata API Patterns

Tutorial
Depth: ●●○○○
Share:

Configure SEO with Next.js metadata file conventions. Dynamic sitemap generation, robots.txt configuration, and the Metadata API for titles, descriptions, and Open Graph images.

Summary of Next.js SEO Setup

Below is a compact reference of the robots, sitemap, and metadata setup you described, suitable as a quick checklist or snippet library.

Key Concepts

robots.ts → Generates /robots.txt to control crawler access.

sitemap.ts → Generates /sitemap.xml listing static and dynamic routes.

Metadata API → Central and per-page SEO configuration via metadata and generateMetadata.

Recommended Disallow Paths

/studio – CMS admin interface

/api/ – JSON API endpoints

/preview – Draft preview routes

/admin – Any admin dashboards