Found a bug in generateMetadata with alternates and openGraph's url. The tags are moved in the body
Unanswered
Asian black bear posted this in #help-forum
Asian black bearOP
Using this demo data, I confirm that on nextjs 15.5.2 the tags are moved at the end of body. it is due from the url present in these data
export async function generateMetadata({ params }: Props) {
const { locale } = await params
const t = await getTranslations({ locale, namespace: "homePage.meta" })
return {
metadataBase: new URL('https://example.com'),
title: { default: 'My Site', template: '%s | My Site' },
description: 'Welcome to My Site',
alternates: {
canonical: 'https://example.com',
languages: {
'en-US': 'https://example.com/en-US',
'de-DE': 'https://example.com/de-DE'
}
},
openGraph: {
title: 'My Site',
description: 'Welcome to My Site',
url: 'https://example.com',
siteName: 'My Site',
images: [{ url: 'https://example.com/og.png' }]
},
}
}
If now I use this data
export async function generateMetadata({ params }: Props) {
const { locale } = await params
const t = await getTranslations({ locale, namespace: "homePage.meta" })
return {
metadataBase: new URL('https://example.com'),
title: { default: 'My Site', template: '%s | My Site' },
description: 'Welcome to My Site',
openGraph: {
title: 'My Site',
description: 'Welcome to My Site',
siteName: 'My Site',
images: [{ url: 'https://example.com/og.png' }]
},
}
}
there are no problem and they appears in the head tag
I've tested with my data, but it has the same problems with default e basic data, so I think it is a bug
export async function generateMetadata({ params }: Props) {
const { locale } = await params
const t = await getTranslations({ locale, namespace: "homePage.meta" })
return {
metadataBase: new URL('https://example.com'),
title: { default: 'My Site', template: '%s | My Site' },
description: 'Welcome to My Site',
alternates: {
canonical: 'https://example.com',
languages: {
'en-US': 'https://example.com/en-US',
'de-DE': 'https://example.com/de-DE'
}
},
openGraph: {
title: 'My Site',
description: 'Welcome to My Site',
url: 'https://example.com',
siteName: 'My Site',
images: [{ url: 'https://example.com/og.png' }]
},
}
}
If now I use this data
export async function generateMetadata({ params }: Props) {
const { locale } = await params
const t = await getTranslations({ locale, namespace: "homePage.meta" })
return {
metadataBase: new URL('https://example.com'),
title: { default: 'My Site', template: '%s | My Site' },
description: 'Welcome to My Site',
openGraph: {
title: 'My Site',
description: 'Welcome to My Site',
siteName: 'My Site',
images: [{ url: 'https://example.com/og.png' }]
},
}
}
there are no problem and they appears in the head tag
I've tested with my data, but it has the same problems with default e basic data, so I think it is a bug
1 Reply
Asian black bear
If you think so, please open an issue on GitHub.