admin管理员组文章数量:1401470
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.
本文标签: javascriptNextJS generateMetadata is rendering outside of the ltheadgt tagStack Overflow
版权声明:本文标题:javascript - NextJS generateMetadata is rendering outside of the <head> tag - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744200514a2594940.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论