Metadata and site_name SEO

hi there, a few questions

Getting this message

metadataBase property in metadata export is not set for resolving social open graph or twitter images

for both dev and production

my configuration

–a

export const metadata = {
  metadataBase: new URL(`${process.env.BASE_URL}`),

–b

export async function generateMetadata({ params, searchParams }) {
  const { category } = params;
  return {
    metadataBase: new URL("https://www.site.name"),

how to declare it correctly?

can not get the site name in the google search, getting only domain url
my configuration

export async function generateMetadata({ params, searchParams }) {
  const { category } = params;
  return {
    openGraph: {
      siteName: "My Site Name",

what could cause this behavior?

thanks!

Hey there,

Please note that: Functions: generateMetadata | Next.js

  • The metadata object and generateMetadata function exports are only supported in Server Components.
  • You cannot export both the metadata object and generateMetadata function from the same route segment.
  • On the initial load, streaming is blocked until generateMetadata has fully resolved, including any content from loading.js.

hi,

in my case, both metadata and generatemetadata are running on the server side

they are exported as follows
metadata from /blogs/layout.js
generatemetadata from /blogs/[slug]/[slug]/page.js

Did you provide BASE_URL Environment variable in Project? This worked for me:

export const metadata = {
  metadataBase: new URL('http://localhost:3000'),
  title: 'Title website',
  description: 'this is the description'
  openGraph: {
    title: 'Title website',
    description: 'this is the description',
    image: 'url/image.png'
  },
  twitter: {
    card: 'summary_large_image',
    site: '@vercel_support',
    title: 'Title website',
    description: 'this is the description',
    image: 'url/image.png'
  }
}

The error metadata.metadataBase is not set for resolving typically occurs when the base URL for metadata is not set, which is needed for resolving social open graph or Twitter images. This warning can appear when running in development mode (localhost), and it will fallback to “http://localhost:3000” if metadataBase is not set.

still getting the issue

metadataBase property in metadata export is not set for resolving social open graph or twitter images, using

error appears for both - dev and production

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.