Title and description
- App Router
- Export
metadataorgenerateMetadatafrom a server route module. - Pages Router
- Render tags with
next/headin the page component. Use thekeyprop on a tag (for exampleog:title) to avoid duplicates.
Set up Next.js SEO by router type, render page metadata on the server, and verify canonicals, robots rules, and sitemap output.
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.
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
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.metadata or generateMetadata from a server route module.next/head in the page component. Use the key prop on a tag (for example og:title) to avoid duplicates.generateMetadata with route params and page data.app/robots.ts and app/sitemap.ts or static files.metadataBase in a root layout or provide absolute values.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.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.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.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.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.',
}
generateSitemaps when needed.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.
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.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.
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.
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.
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, canonical metadata, robots.txt, and Google Search Console submission.
4 questions people ask next, answered from the sources on this page.
In the App Router, export metadata or generateMetadata from a Server Component route. In the Pages Router, use next/head in the page component.
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.
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.
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.
Run the free audit, then approve the fixes. Every change can be undone.