I'm having SEO issues with a nextJS app where the meta data is being outputted outside of the body tag. I have this bit of code in my page.tsx file
export async function generateMetadata(
{ params, searchParams }: Props,
parent: ResolvingMetadata
): Promise<Metadata> {
void searchParams;
void parent;
const {business, city, category} = await params
return await generateBusinessMetadata({
businessSlug: business,
city: city,
category: category,
});
}
inside generateBusinessMeta data there is a supabase data fetch.
Weirdly, if I hard refresh the meta data shows in the head, but when I do a normal refresh it moves down below the script tags at the bottom of the page. This is causing all sorts of issues with SEO, and my impressions have plummeted, any ideas what is going on?
I'm using the app router on Next 15.2.3
I'm having SEO issues with a nextJS app where the meta data is being outputted outside of the body tag. I have this bit of code in my page.tsx file
export async function generateMetadata(
{ params, searchParams }: Props,
parent: ResolvingMetadata
): Promise<Metadata> {
void searchParams;
void parent;
const {business, city, category} = await params
return await generateBusinessMetadata({
businessSlug: business,
city: city,
category: category,
});
}
inside generateBusinessMeta data there is a supabase data fetch.
Weirdly, if I hard refresh the meta data shows in the head, but when I do a normal refresh it moves down below the script tags at the bottom of the page. This is causing all sorts of issues with SEO, and my impressions have plummeted, any ideas what is going on?
I'm using the app router on Next 15.2.3
Share Improve this question asked Mar 25 at 11:23 Elliott CoeElliott Coe 5833 gold badges6 silver badges20 bronze badges1 Answer
Reset to default 0This is expected behavior. Next.js 15.2 introduced a new feature called streaming metadata. With this update, metadata is streamed to the UI as and when it becomes available. If you're performing dynamic data fetching or asynchronous operations within generateMetadata
, the metadata may not be available when the initial UI is ready. So the UI will be sent to the browser before generateMetadata
has completed.
And when the metadata is streamed, it will be placed in the <body>
tag.
However, as noted in the blog post, this will not impact SEO. Search engine bots and crawlers will receive the HTML only after the metadata has been fully generated.
You can configure the user agents which should receive the blocking metadata using the htmlLimitedBots
config.