The title and meta tags from generateMetadata show up inside <body>
Your error
<title> and <meta name="description"> appear after <body> in view-source2 more lines it can showFix it fast
Most common cause, 1 of 3generateMetadata depends on request-time data, so it is streamed
If your target crawlers run JavaScript, nothing needs fixing.
// next.config.js
module.exports = {
htmlLimitedBots: /.*/,
}Short answer
This is streaming metadata, added in Next.js 15.2. When generateMetadata waits on request-time data, Next.js sends the page first and appends the tags to <body> once they resolve. Bots that run JavaScript, such as Googlebot, read them from the DOM; HTML-only bots get them in <head>. To force <head> for everyone, set htmlLimitedBots: /.*/ or make the metadata static.
Which cause do you have?
Fetch the same URL with two user agents and see where the title lands. A difference between them means streaming metadata, not a bug in your layout.
curl -s -A "Mozilla/5.0 Chrome/131" https://example.com/page | grep -o '<title>[^<]*'
curl -s -A "facebookexternalhit/1.1" https://example.com/page | grep -o '<title>[^<]*'Then find the line you see in this list and open its fix:
- 1generateMetadata depends on request-time data, so it is streamed
Browsers and Googlebot get the tags after <body>; facebookexternalhit gets them in <head> - 2A crawler you care about is missing from the default bot list
One social preview or SEO tool shows no title while Google and Facebook show it - 3The page could be static, but the metadata makes it dynamic
The route shows as dynamic (ƒ) in next build only because generateMetadata reads cookies, headers or searchParams
What does the error look like?
<title> and <meta name="description"> appear after <body> in view-sourceMeta tags are moving to the <body> tag instead of the <head> tagAn SEO checker says the page has no title or description in the head
Cause 1 of 3
generateMetadata depends on request-time data, so it is streamed
You seeBrowsers and Googlebot get the tags after <body>; facebookexternalhit gets them in <head>
Check
Find the generateMetadata of that route and see whether it awaits cookies(), headers(), searchParams or uncached data. If it does, the response starts before the tags exist, so they arrive later inside the body. Crawlers that execute JavaScript read them from the finished DOM; HTML-limited crawlers are made to wait and get them in the head.
grep -rnE "generateMetadata|cookies\(|headers\(|searchParams" app --include=page.* --include=layout.*Fix
If your target crawlers run JavaScript, nothing needs fixing. If a tool you rely on does not, disable streaming for every user agent with the htmlLimitedBots option (Next.js 15.2.0 or later).
// next.config.js
module.exports = {
htmlLimitedBots: /.*/,
}Verify
Rebuild and fetch the page as a normal browser; the title now comes before <body>.
curl -s -A 'Mozilla/5.0 Chrome/131' http://localhost:3000/page | grep -o '<title>[^<]*'Confirmed by nextjs.org
Cause 2 of 3
A crawler you care about is missing from the default bot list
You seeOne social preview or SEO tool shows no title while Google and Facebook show it
Check
Next.js ships a default list of HTML-limited bots. A custom value replaces that list rather than adding to it, so a pattern that names only your extra bot drops the defaults.
grep -n htmlLimitedBots next.config.*Fix
Write a pattern that covers your extra user agent and the crawlers you still need, or use /.*/ if you prefer blocking metadata for everyone.
module.exports = {
htmlLimitedBots: /facebookexternalhit|Twitterbot|LinkedInBot|Slackbot|MyCrawler/,
}Verify
Fetch the page with that crawler's user agent string and confirm the tags sit in the head.
curl -s -A 'MyCrawler/1.0' http://localhost:3000/page | grep -o '<title>[^<]*'Confirmed by nextjs.org
Cause 3 of 3
The page could be static, but the metadata makes it dynamic
You seeThe route shows as dynamic (ƒ) in next build only because generateMetadata reads cookies, headers or searchParams
Check
A prerendered page whose generateMetadata adds no request-time behaviour has its tags baked into the first HTML. Removing the one headers() or cookies() call is often enough to turn the route from ƒ into ○ in the build output.
npx next build | grep -E '○|ƒ'Fix
Build the metadata from params and cached data only, or use the static metadata object when the values do not change per request.
// app/about/page.tsx
export const metadata = {
title: 'About',
description: 'What this site is about.',
}Verify
next build lists the route as static, and the title is inside the head of the built HTML.
curl -s http://localhost:3000/about | grep -o '<title>[^<]*'Confirmed by nextjs.org
How do I stop it coming back?
- Keep generateMetadata free of cookies() and headers() unless the tags really differ per visitor.
- Test social previews with the platform's own debugger after each Next.js upgrade.
- Check view-source and the rendered DOM separately; streamed tags only exist in the second.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.