How to create a meta tag with "property" field instead of "name" using generateMetadata function
Answered
French Angora posted this in #help-forum
French AngoraOP
I am trying to create this meta tag:
In generateMetadata function I am returning this:
It's creating meta tag with "name" field
How can I create a metatag with property field?
<meta property="lb:id" content="...">
In generateMetadata function I am returning this:
return {
other: {
"lb:id": product?.sku,
}
}
It's creating meta tag with "name" field
<meta name="lb:id" content="...">
How can I create a metatag with property field?
11 Replies
you can just render the tag directly in the page
Answer
IIRC you can do this
export async function generateMetadata({ params }: { params: { id: string } }): Promise<Metadata> {
return {
title: 'Product Page',
meta: [
{ property: 'lb:id', content: "..." },
],
};
}
Object literal may only specify known properties, and 'meta' does not exist in type 'Metadata'.ts(2353)
i was a bit surprised that this wasn't already the case, but yeah that is not allowed. wish nextjs team allowed this though
French AngoraOP
I tried it but it doesn't work
Hmm, Yes, it can't be used.
I might be confused with some other properties.
I might be confused with some other properties.
I guess you can use the
meta
tag onlyits there in stable also
generateParams doesn't have other tag, i might create a pr to fix that
French AngoraOP
I just added the meta tag directly inside the component and it's working.
return (
<>
<meta property="lb:id" content={product?.sku} />
<PdpSeoData productSchema={productSchema} product={product} />
<RenderBuilderContent content={content} model="pdp-template" />;
</>
);