Next.js Discord

Discord Forum

Cant add custom metadata with property=

Answered
Pink-footed Shearwater posted this in #help-forum
Open in Discord
Avatar
Pink-footed ShearwaterOP
Hi there,

So I am trying to incorporate a custom metadata tag like this:

<meta property="prepr:id" content="16c63a1e-e837-4951-bd9a-b933a8d14b2f"/>


In Next 13 using the App directory. I am struggling since this meta tag needs to have a property and content.

However when looking around online the online option I could find on adding custom metadata was using the other: {
// Content
}

So I tried it like this
export async function generateMetadata({ params }) {
  const { slug } = params;
  const data = await getData(slug);

  return {
    title: data.Page.title,
    other: {
      'prepr:id': data.Page._id
    }
  };
}


But this results in a name= instead of property=

Any idea on how I can achieve adding a metadata with property=
Answered by joulev
Try simply adding that tag to the page. I think react will automatically hoist it to <head>
View full answer

3 Replies

Avatar
joulev
Try simply adding that tag to the page. I think react will automatically hoist it to <head>
Answer
Avatar
Pink-footed ShearwaterOP
I didn't know that was possible. It resolved the issue, thanks.
Avatar
joulev
be careful though that it could break at any time, since it's not covered by semver. after each nextjs updates please check if it's still working properly – if you have a testing system please add a test case for this