Next.js Discord

Discord Forum

Twitter image not working

Unanswered
Pacific anchoveta posted this in #help-forum
Open in Discord
Pacific anchovetaOP
I have struggled for days now with getting the metadata to work properly, and I still can't get the Twitter image to show. I have both the OG and Twitter image stored locally, and OG works fine. I'll share the metadata object here:

const someTitle = "My title;
const someDescription ="My description.";

export const metadata: Metadata = {
  title: someTitle,
  description: someDescription,
  metadataBase: process.env.VERCEL_URL
    ? new URL(`https://www.myDomain.com`)
    : new URL(`http://localhost:${process.env.PORT || 3000}`),
  alternates: {
    canonical: "./",
  },
  openGraph: {
    title: someTitle,
    description: someDescription,
    url: "https://www.myDomain.com",
    type: "website",
    images: [
      {
        url: ogImage.src,
        width: 1200,
        height: 630,
        alt: "myDomain Open Graph Image",
      },
    ],
  },
  twitter: {
    title: someTitle,
    description: someDescription,
    card: "summary_large_image",
    site: "@myDomain",
    creator: "@myDomain",
    images: {
      url: twitterImage.src,
      alt: "myDomain Twitter Image",
    },
  },
};


Anyone have any clue what is wrong here?

1 Reply

Pacific anchovetaOP
This is a real nightmare for me, nothing seems to work. The image can be seen on the site by going into the meta tag url, but refuses to show when the link is shared. All of the other information is shown. I've tried with and without height/width.