Next.js SEO

A developer-friendly guide to shipping Next.js pages that are indexable, shareable, and fast: Metadata API, Open Graph, canonicals, robots/sitemaps, structured data, and performance checks.

  • 🏷️ Metadata API
  • 🧭 Canonicals
  • 🧾 robots + sitemap
  • 🏷️ Schema
  • ⚡ Core Web Vitals

What this guide covers

Next.js makes SEO easier when you apply consistent patterns: set strong defaults once, override per route, keep canonical URLs clean, generate sitemaps, and avoid accidental noindex in production.

Outcomes

  • Correct titles/descriptions across all routes
  • Valid OG/Twitter previews when shared
  • Canonical URLs that prevent duplicates
  • Clean robots + sitemap setup
  • Structured data for clarity + eligibility (where appropriate)
  • Performance checks that protect UX and SEO

Recommended reading path

Read in this order and implement step-by-step.

2) Technical SEO Basics

Indexability, status codes, internal linking, and the usual reasons pages don’t show up.

Foundation • Indexing

4) Image Optimization

Formats, sizing, responsive images, and loading strategy—big wins for LCP.

Deep dive • Images

Project kit

Want templates you can copy-paste? Use: SEO Starter.

Key Next.js SEO topics

The concepts you should implement once and reuse everywhere.

Metadata defaults

Set global defaults in layout, then override per route. Keep titles unique and descriptions useful.

Open Graph previews

Ensure every shareable page has OG/Twitter tags and a stable image URL.

Canonical URLs

Pick a preferred URL format (host + trailing slash rule) and stick to it across all pages.

Robots rules

Don’t accidentally block important pages. Avoid shipping noindex to production.

Sitemaps

Include only canonical, indexable URLs—no redirects, no parameter variants.

Structured data

Use schema for clarity (BlogPosting, Breadcrumbs, FAQ where relevant). Don’t spam markup.

Next.js SEO deployment checklist

A fast pre-ship checklist to avoid common production mistakes.

Indexing

  • No accidental noindex
  • robots.txt allows key routes
  • Canonical points to preferred URL
  • Pages return 200 (not 3xx/4xx)

Metadata

  • Unique titles per page
  • Descriptions match content
  • OG/Twitter previews correct
  • Canonical format consistent

Sitemap & structure

  • sitemap.xml is reachable
  • Only canonical URLs included
  • Internal links connect important pages
  • Breadcrumbs for deep pages

Performance

  • LCP element optimized (often hero)
  • CLS prevented (reserved space)
  • INP improved (reduce long tasks)
  • Images sized correctly

FAQ

Common Next.js SEO questions.

Best way to do SEO in Next.js?

Use Metadata API for defaults + per-route overrides, keep canonicals consistent, generate sitemap, and validate indexability.

Static vs dynamic metadata?

Prefer static where possible. Use dynamic for content pages (posts/products). Keep defaults at layout level.

How to avoid duplicate URLs?

Pick a preferred format and canonicalize consistently. Don’t index parameter variants.

Do I need schema?

Not required, but it improves clarity and rich result eligibility where appropriate.

Want copy-paste templates?

Use SEO Starter for baseline templates, then validate performance with Performance Audit Kit.