Next.js Discord

Discord Forum

<meta> tags and url's

Answered
Pacific anchoveta posted this in #help-forum
Open in Discord
Pacific anchovetaOP
Hey, everyone.

I'm currently trying to configure the metadata on a Next 13.4 (app dir) site, and I see that i.e. when I share a post on FB or Twitter, if I prepend the URL with https:// the twitter/og image shows in the post, however if i just share it like this www.mysite.com the image does not show, but the other metadata (title + desccription) do show.

I export generateMetadata both from my root layout.tsx and in my app/gallery/[slug]/page.tsx. Will the openGraph.images in my ...[slug]/page.tsx override the same property exported in my root layout.tsx ?

My generateMetadata() function return statement (root layout) currently looks like this:

return {
    title: {
      template: `%s | ${siteData.seo.title}`,
      default: siteData.seo.title,
    },
    description: siteData.seo.description,
    twitter: {
      card: "summary_large_image",
      title: siteData.seo.title,
      description: siteData.seo.description,
      images: [metaImageUrl],
    },
    openGraph: {
      title: siteData.seo.title,
      description: siteData.seo.description,
      url: "https://www.mysite.com",
      siteName: siteData.seo.title,
      images: [metaImageUrl],
      locale: "en",
      type: "website",
    },
  };

The one inin my app/gallery/[slug]/page.tsx looks the same, pretty much.

Can anyone see what could be done to fix this?

All help highly appreciated 🙏
Answered by Pacific anchoveta
I foubd the solution, actually. The problem was the url property of the metaData object. I passed the baseUrl originally, but when I changed this to the pathname (base + slug), it worked 🙂
View full answer

4 Replies

Thrianta
what is the image you're exporting exactly?
what is it's path?
if you do not mind sharing
Pacific anchovetaOP
I foubd the solution, actually. The problem was the url property of the metaData object. I passed the baseUrl originally, but when I changed this to the pathname (base + slug), it worked 🙂
Answer