Free auditStart free
GuideNext.js · Framework guide

Next.js SEO

Set up Next.js SEO by router type, render page metadata on the server, and verify canonicals, robots rules, and sitemap output.

5 min
read
7
sources
Oct 24, 2026
updated
Scaplet Editorial Team
author
In one line

Identify whether the app uses the App Router or Pages Router. In App Router, export metadata or generateMetadata from Server Components and set metadataBase; use metadata files for robots and sitemap. In Pages Router, use next/head. Render unique metadata and useful content in the initial response, then verify canonical URLs, status codes, and sitemap coverage on production routes.

30-second check

Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode
02Checklist

Give every indexable route accurate metadata

Set a sitewide title template and default description, then override them where a page has a different search purpose. For a product, article, or location route, derive metadata from the same record that supplies the visible page. Avoid generating hundreds of title variants that differ only by a city or keyword when the underlying content is otherwise identical.
  1. 01Use metadataBase only for the production origin that should appear in URL-valued fields such as canonical and Open Graph image URLs. Next.js says it is typically set in the root app/layout, and that a relative path in a URL-based field without metadataBase causes a build error.
  2. 02Use generateMetadata when a route needs database or CMS data. Next.js says notFound() and redirect() can be called inside it, so handle missing records as a real not-found state rather than emitting metadata for an empty page. fetch requests inside it are memoized with the page's own requests.
  3. 03Keep metadata and visible page content consistent. A title cannot compensate for a page that does not satisfy the query or explain the offer.
  4. 04Set canonical URLs for routes with known duplicates, such as parameterized variants, with alternates: { canonical: '/path' }, which Next.js resolves against metadataBase into a <link rel="canonical"> tag. A canonical is a hint; also clean internal links and avoid creating duplicates unnecessarily.
  5. 05Add social metadata for sharing where useful, but do not confuse Open Graph tags with a Google ranking factor.
  6. 06title.template set in a layout applies to child segments only, not to a title in a page of the same segment, and title.default is required with a template. Nested objects such as openGraph and robots defined in an earlier segment are overwritten, not merged, by a later segment that defines them.
App Router metadata
import type { Metadata } from 'next'

export const metadata: Metadata = {
  metadataBase: new URL('https://example.com'),
  title: { default: 'Acme', template: '%s | Acme' },
  description: 'A specific description of the page.',
}
04How it works

Publish clean crawl rules and a sitemap

The App Router supports metadata file conventions for robots and sitemap output: a static app/robots.txt, or app/robots.ts returning a Robots object, and likewise app/sitemap.ts. Next.js says robots.js is a Route Handler cached by default unless it uses a Request-time API or dynamic config option. A dynamic sitemap can be built from the canonical records in a CMS or database. Keep it limited to public canonical URLs that return successfully; remove drafts, staging hosts, redirects, and noindex pages.
  1. 1

    Check every route family

    Sample static pages, dynamic detail pages, localized routes, and paginated or filtered pages. Confirm each has an index policy that matches its value and duplication risk.

  2. 2

    Inspect robots and sitemap endpoints

    Open /robots.txt and /sitemap.xml on production. Confirm the sitemap uses the canonical origin and the robots file does not block pages or resources required for rendering.

  3. 3

    Validate important structured data

    If the page emits product, article, or organization markup, ensure it matches visible content and current Google eligibility. Avoid emitting the same entity from multiple components or plugins.

  4. 4

    Review Search Console

    Submit the sitemap, inspect sample URLs, and compare query and page performance after deployments. Fix source data or route code when the same defect appears across a template.

Questions

Asked a lot.

4 questions people ask next, answered from the sources on this page.

01How do I add SEO metadata in Next.js?

In the App Router, export metadata or generateMetadata from a Server Component route. In the Pages Router, use next/head in the page component.

02Can a Next.js Client Component export metadata?

No. App Router metadata exports are supported in Server Components. Keep route metadata in the server page or layout and render interactive components beneath it.

03Does Next.js automatically create a sitemap?

The App Router supports a sitemap.ts metadata file convention, but you must define the sitemap entries for your routes and data. Verify all intended public URLs in the generated output.

04Is SSR required for Next.js SEO?

No single rendering mode fits every route. Use static generation, revalidation, or SSR according to content freshness and user-specific needs, then verify the initial HTML and indexing behavior.

Sources · 7

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • nextjs.org
  • google.com
  1. 01Metadata and OG images | Next.js Docsnextjs.org · checked 2026-10-24
  2. 02generateMetadata | Next.js API Referencenextjs.org · checked 2026-10-24
  3. 03sitemap.xml | Next.js Metadata Filesnextjs.org · checked 2026-10-24
  4. 04robots.txt | Next.js Metadata Filesnextjs.org · checked 2026-10-24
  5. 05Head | Next.js Pages Routernextjs.org · checked 2026-10-24
  6. 06Understand JavaScript SEO basics | Google Search Centraldevelopers.google.com · checked 2026-10-24
  7. 07SEO Starter Guide | Google Search Centraldevelopers.google.com · checked 2026-10-24
Free · 2 minutes

Tools point. Agencies advise. This one ships.

Run the free audit, then approve the fixes. Every change can be undone.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • 0→7 ChatGPT citations in six weeks Paylane