Next.js App Router SEO: what 177 sites miss on inner pages, and the metadata fixes
We fetched the home pages of 285 Next.js sites in November 2026; 193 of them use the App Router. Home pages were mostly in order: 5% had no meta description, 11% no og:image, 12% no canonical link. The gaps are one level down. On 356 inner pages from 177 App Router sites, fetched the way link previewers fetch them, 15% had no og:image, 13% no canonical and 10% no description; 35% carried no JSON-LD. On 12 sites the home page had a share image and an inner page had none, which is what Next.js's metadata merging does by default (section 2).
Below is the setup that avoids each gap, checked against the Next.js 16.4 documentation and tested on a production build of Next.js 16.4.6.
1. Root layout: metadataBase and a title template
// app/layout.js
export const metadata = {
metadataBase: new URL('https://www.example.com'),
title: { template: '%s | Example', default: 'Example' },
description: 'What the site is about, in one or two sentences.',
};
metadataBase lets every URL field below it be a path (/blog/launch, /og.png); Next.js joins the two and removes the duplicate slash. Without it, the build only warns: relative share-image paths are resolved against http://localhost:3000 (on Vercel, the deployment URL), and a relative canonical is printed as-is, so previewers get a URL they can't load. A child page's title: 'Pricing' becomes "Pricing | Example". The template only applies to child segments, never to the page.js next to the layout, and title.absolute skips it.
The description here is a site-wide fallback. Every page that doesn't set its own shows the same text in search results, so set one per page (section 3).
2. openGraph is replaced, not merged
Next.js merges the metadata of a layout and its pages shallowly. A page that sets openGraph at all replaces the layout's whole openGraph object, including its images:
// app/layout.js
export const metadata = {
openGraph: { siteName: 'Example', images: ['/og.png'] },
};
// app/blog/page.js
export const metadata = {
openGraph: { title: 'Blog' },
};
// /blog gets og:title "Blog" and no og:image, no og:site_name
The same goes for twitter, robots and alternates. A page that sets none of them inherits the layout's whole object instead. If that object has a title or description, every such page is shared with the site's title and text; leave them out of the layout and og:title follows each page's own title. The fix from the Next.js docs is a shared object that each page spreads into its own:
// app/shared-metadata.js
export const openGraphBase = { siteName: 'Example', images: ['/og.png'] };
// app/blog/[slug]/page.js
import { openGraphBase } from '../../shared-metadata';
export async function generateMetadata({ params }) {
const { slug } = await params;
const post = await getPost(slug);
return {
title: post.title,
description: post.summary,
alternates: { canonical: `/blog/${slug}` },
openGraph: {
...openGraphBase,
type: 'article',
title: post.title,
description: post.summary,
url: `/blog/${slug}`,
...(post.image && { images: [post.image] }),
},
};
}
Use PNG or JPG for share images, around 1200×630; previewers don't render SVG. If a card still shows no picture, og:image not showing covers the other causes.
3. Canonical: per page, never in the root layout
Next.js prints no canonical link unless alternates.canonical is set. Set it in each page's metadata, as above. Putting alternates: { canonical: '/' } in the root layout looks tidy, but every page that doesn't set its own inherits it, and each of those pages then tells Google the home page is the real one. With metadataBase set, a path is enough; query strings like ?utm_source= are not part of it, so tagged links point back to the clean URL.
4. Share images from files
Instead of openGraph.images, you can put an opengraph-image.png (or .jpg, .gif) into a route segment, with an opengraph-image.alt.txt next to it for the alt text. twitter-image works the same way. Above 8 MB for Open Graph or 5 MB for X, the build fails. An opengraph-image.js that default-exports a function returning an ImageResponse from next/og draws the image from the page's data, for example the post title on a 1200×630 card.
5. Streamed metadata: why view-source may show an empty head
Since Next.js 15.2, the HTML starts streaming before an async generateMetadata has finished, and the tags are appended to <body> when it resolves. Browsers and crawlers that run JavaScript, Googlebot included, handle that. For "HTML-limited" bots Next.js waits and puts the tags in <head>: it recognises them by User-Agent, including facebookexternalhit, LinkedInBot, Twitterbot, Slackbot, Discordbot, WhatsApp, Bingbot and DuckDuckBot.
So view-source in a browser, or a fetch with a browser's User-Agent, can show a head with no description and no Open Graph tags on a dynamic page, while link previews work (in our test, a plain curl got the tags in the head). Check with a previewer's User-Agent (section 8). If another tool you depend on needs the tags in the head, htmlLimitedBots: /.*/ in next.config.js turns streaming off, at the cost of a slower first byte.
6. JSON-LD: a script tag in the page, with < escaped
The Metadata API has no field for structured data. Next.js recommends rendering it as a script tag in the page or layout, with < replaced, so a title containing </script> can't end the tag:
// app/blog/[slug]/page.js
export default async function Page({ params }) {
const { slug } = await params;
const post = await getPost(slug);
const jsonLd = {
'@context': 'https://schema.org',
'@type': 'BlogPosting',
headline: post.title,
description: post.summary,
datePublished: post.date,
url: `https://www.example.com/blog/${slug}`,
};
return (
<article>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd).replace(/</g, '\\u003c') }}
/>
{/* ... */}
</article>
);
}
Paste a published page into the structured data checker to see what parses. Skip FAQPage markup unless you're a government or health site: Google no longer shows it as a rich result for anyone else.
7. sitemap.js, robots.js and noindex
// app/sitemap.js
export default async function sitemap() {
const posts = await getPosts();
return [
{ url: 'https://www.example.com/', lastModified: new Date() },
...posts.map((p) => ({ url: `https://www.example.com/blog/${p.slug}`, lastModified: p.updated })),
];
}
// app/robots.js
export default function robots() {
return {
rules: { userAgent: '*', allow: '/' },
sitemap: 'https://www.example.com/sitemap.xml',
};
}
Both are served at /sitemap.xml and /robots.txt. Sitemap URLs must be absolute; metadataBase doesn't apply here. To keep a page out of search, set robots: { index: false } in its metadata and leave it out of the sitemap. Don't block it in robots.txt as well: a blocked page can't be crawled, so Google never sees the noindex.
8. Check what a previewer gets
curl -s -A 'facebookexternalhit/1.1' https://www.example.com/blog/launch | grep -E -o '<(title|link rel="canonical"|meta (name|property)="(description|og:[a-z:]+|twitter:card|robots)")[^>]*>'
curl -s https://www.example.com/sitemap.xml | grep -c '<loc>'
Run the first line on an inner page, not only the home page: that's where the audited sites lost their images. To check many pages at once, run up to 50 pages from your sitemap through the free site checker: it lists pages with no description, no share image or a shared title.
Automating it with Headlark
Writing a description and share text for every page is the slow part. With a static export, Headlark runs after next build and writes the title, description and Open Graph/X tags into each HTML file from the page's own content; it keeps the canonical, robots and JSON-LD your metadata sets. Pages rendered on request have no HTML at build time; for those, use the deploy hook with the snippet.
Try it
Try it free for 14 days on one site and up to 500 pages, no card needed. Add your site.