What you'll learn
- Unique title and description per indexable route
- Canonical URL, OG image, and robots rules
- Sitemap and robots.txt that agree on the hostname
- JSON-LD for articles and breadcrumbs
Direct answer: every public page needs its own title, description, canonical, and social image. Add a sitemap of those URLs, declare it in robots.txt, and emit JSON-LD that matches what users see. Prefer server-rendered HTML so crawlers see content without waiting on client fetch.
This page is the Next.js SEO cluster hub. Pair it with Rendering Strategies and Update Content Without Redeploying.
When to use this
- Launching or auditing a Next.js marketing or handbook site
- Dynamic routes need per-slug metadata
- Search Console shows missing or duplicate titles
When not to use this
- Fully private authenticated apps with
noindexby design - You only need React runtime performance tips: see Performance
App Router pattern
// app/articles/[slug]/page.tsx
import type { Metadata } from 'next'
export async function generateMetadata({ params }): Promise<Metadata> {
const article = await getArticle(params.slug)
const url = `https://www.example.com/articles/${article.slug}`
return {
title: `${article.title} | Example`,
description: article.description,
alternates: { canonical: url },
openGraph: {
title: article.title,
description: article.description,
url,
type: 'article',
images: [{ url: article.ogImage }],
},
}
}Also add app/sitemap.ts and app/robots.ts (or static files) so the sitemap lists only canonical, indexable URLs.
Pages Router pattern
Centralize <Head> (or a shared Seo component) with title, description, canonical, OG, Twitter, and JSON-LD. Build sitemap.xml at build time from your content index. ReactField uses this approach.
Checklist
- One
<title>and one meta description per indexable route - Visible
<h1>matches the topic - Canonical uses the preferred host (
wwwor apex), consistently - OG title, description, and image present
-
robots.txtallows important paths and points at the sitemap - Sitemap omits
noindex, previews, and utility routes - Optional
/llms.txt(and/llms-full.txt) for LLM agent discovery - JSON-LD validates in Rich Results Test for a sample article
- Article HTML is present in View Source, not only after hydration
Common mistakes
- Default title reused on every page
- Sitemap on a different host than the canonical
- Client-only content with empty first HTML
- Using
robots.txtinstead ofnoindexfor soft-private pages
Related
Final recommendation
Treat SEO as route data: unique metadata, stable canonicals, a clean sitemap, and HTML that already contains the article. Framework APIs differ between App and Pages Router; the checklist does not.