# 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.

Canonical: https://scaplet.com/seo/nextjs

Guide Next.js Next.js · Framework guide

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 with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fnextjs%20(%22Next.js%20SEO%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fnextjs%20(%22Next.js%20SEO%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fnextjs%20(%22Next.js%20SEO%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fnextjs%20(%22Next.js%20SEO%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

On this page

## 4 parts, 5 minutes.

1. [Choose the SEO API for your router 01](#choose-the-seo-api-for-your-router)
2. [Give every indexable route accurate metadata 02](#give-every-indexable-route-accurate-metadata)
3. [Render content and metadata in the response crawlers receive 03](#render-content-and-metadata-in-the-response-crawlers-receive)
4. [Publish clean crawl rules and a sitemap 04](#publish-clean-crawl-rules-and-a-sitemap)

_01_App Router and Pages Router SEO

## Choose the SEO API for your router

Next.js has two routing systems with different metadata conventions. The App Router uses file conventions and exports from route layouts or pages. The Pages Router uses the `Head` component from `next/head`. Identify the router in your repository before copying examples: many apps use both during migration, but a route belongs to one system at a time.

Area

### Title and description

App Router

Export `metadata` or `generateMetadata` from a server route module.

Pages Router

Render tags with `next/head` in the page component. Use the `key` prop on a tag (for example `og:title`) to avoid duplicates.

Area

### Dynamic page metadata

App Router

Use async `generateMetadata` with route params and page data.

Pages Router

Build the head content from the page's fetched props.

Area

### Robots and sitemap

App Router

Use `app/robots.ts` and `app/sitemap.ts` or static files.

Pages Router

Create routes or public files that return the required robots and sitemap content.

Area

### Absolute metadata URLs

App Router

Set `metadataBase` in a root layout or provide absolute values.

Pages Router

Set fully qualified URLs in the page head yourself.

**Metadata exports are server-only**In the App Router, `metadata` and `generateMetadata` are supported in Server Components. A Client Component cannot export them. Put data-dependent metadata in the route's server page or layout, and pass client interactivity below it.

_02_Checklist

## 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. 01 Use `metadataBase` only for the production origin that should appear in URL-valued fields such as canonical and [Open Graph image](/glossary/og-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. 02 Use `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. 03 Keep metadata and visible page content consistent. A title cannot compensate for a page that does not satisfy the query or explain the offer.
4. 04 Set 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](/glossary/internal-links) and avoid creating duplicates unnecessarily.
5. 05 Add social metadata for sharing where useful, but do not confuse [Open Graph](/glossary/open-graph) tags with a Google ranking factor.
6. 06 `title.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.', }
```

_03_Pick a rendering approach by page need

## Render content and metadata in the response crawlers receive

Google says Search runs JavaScript with an evergreen Chromium, but also that server-side or [pre-rendering](/glossary/static-site-generation) is still a great idea because not all bots can run JavaScript. [Server rendering](/glossary/server-side-rendering) or static generation makes primary content available in the initial HTML. Choose [rendering](/glossary/rendering) per route: public reference content and product pages often fit static generation or revalidation; personalized account pages should not be [indexable](/glossary/indexability); pages that depend on fresh server data may need SSR.

Page need

### Stable public content

Common approach

Static generation or cached server rendering.

SEO check

HTML includes the main answer, title, and links before client [hydration](/glossary/hydration).

Page need

### Frequently updated product data

Common approach

Server rendering or revalidation with cache rules.

SEO check

Price, availability, and structured data agree at crawl time.

Page need

### Personalized or private route

Common approach

Client or server rendering behind authentication.

SEO check

Use access control and a deliberate noindex strategy; do not expose private data in a public sitemap.

Page need

### Large dynamic catalog

Common approach

Dynamic route generation plus a generated sitemap, split with `generateSitemaps` when needed.

SEO check

Ensure every intended URL is emitted. Next.js notes Google's limit of 50,000 URLs per sitemap and shows `generateSitemaps` for splitting; in v16 its `id` argument is a promise that resolves to a string.

Inspect production page source or the first HTML response, not only the hydrated browser DOM. Check that the title is unique, the main text exists, internal links are ordinary anchors, and the route returns the correct 200, redirect, or not-found status. Since Next.js 15.2, streaming metadata can send the initial UI before `generateMetadata` resolves; Next.js says the tags are then appended to the `<body>` and that it verified bots that execute JavaScript, such as Googlebot, interpret them correctly. HTML-limited bots such as `facebookexternalhit` still get metadata in the `<head>`, detected from the User Agent. You can override that list with `htmlLimitedBots` in the Next.js config.

_04_How 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.

Use the focused guides for [Next.js sitemap generation](/seo/nextjs/xml-sitemap), [canonical metadata](/seo/nextjs/canonical-tags), [robots.txt](/seo/nextjs/robots-txt), and [Google Search Console submission](/seo/google-search-console/sitemap-submission).

Questions

## Asked a lot.

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

_01_ How 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.

_02_ Can 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.

_03_ Does 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.

_04_ Is 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. 01 [Metadata and OG images | Next.js Docs](https://nextjs.org/docs/app/getting-started/metadata-and-og-images) nextjs.org · checked 2026-10-24
2. 02 [generateMetadata | Next.js API Reference](https://nextjs.org/docs/app/api-reference/functions/generate-metadata) nextjs.org · checked 2026-10-24
3. 03 [sitemap.xml | Next.js Metadata Files](https://nextjs.org/docs/app/api-reference/file-conventions/metadata/sitemap) nextjs.org · checked 2026-10-24
4. 04 [robots.txt | Next.js Metadata Files](https://nextjs.org/docs/app/api-reference/file-conventions/metadata/robots) nextjs.org · checked 2026-10-24
5. 05 [Head | Next.js Pages Router](https://nextjs.org/docs/pages/api-reference/components/head) nextjs.org · checked 2026-10-24
6. 06 [Understand JavaScript SEO basics | Google Search Central](https://developers.google.com/search/docs/crawling-indexing/javascript/javascript-seo-basics) developers.google.com · checked 2026-10-24
7. 07 [SEO Starter Guide | Google Search Central](https://developers.google.com/search/docs/fundamentals/seo-starter-guide) developers.google.com · checked 2026-10-24

## Keep learning

[All platform guides](/seo)

[Learn Next.js XML sitemap Frameworks](/seo/nextjs/xml-sitemap) [Related Structured data Structured data](/glossary/structured-data) [Read next Next.js robots.txt Frameworks](/seo/nextjs/robots-txt) [Do Run a free site audit Free, about two minutes](/site-audit)

Nearby in platform guides
[Mintlify noindex pages](/seo/mintlify/noindex) [Mintlify redirects](/seo/mintlify/redirects) [Next.js 404 page](/seo/nextjs/404) [Next.js AI crawlers](/seo/nextjs/ai-crawlers)

More in Frameworks
[Angular SEO](/seo/angular) [Astro SEO](/seo/astro) [Gatsby SEO](/seo/gatsby) [Next.js SEO](/seo/nextjs) [Nuxt SEO](/seo/nuxt)

Terms on this page
[OG image (og:image)](/glossary/og-image) [Internal links](/glossary/internal-links) [Open Graph](/glossary/open-graph) [Static site generation](/glossary/static-site-generation) [Server-side rendering](/glossary/server-side-rendering) [Rendering](/glossary/rendering) [Indexability](/glossary/indexability) [Hydration](/glossary/hydration)

Free · 2 minutes

## Tools point. Agencies advise. _This one ships._

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

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **0→7** ChatGPT citations in six weeks Paylane
