KEMBAR78
OpenGraph Metdata handling doesn't retain URL parameters for main page · Issue #74689 · vercel/next.js · GitHub
Skip to content

OpenGraph Metdata handling doesn't retain URL parameters for main page #74689

@CodingFabian

Description

@CodingFabian

Link to the code that reproduces this issue

https://github.com/CodingFabian/nextjs-og-param-issue

To Reproduce

The issue is very straightforward. the reproduction is in the repository but is just in this code block:

export const metadata: Metadata = {
  metadataBase: new URL('https://nextjs.org'),
  openGraph: {
    type: "website",
    url: "./?utm=tracking",
    images: ["/images/og-image.png"],
  },
}

The intended use case is to put an open graph metadata containing a tracking code. but it could be any url parameter.
Above renders:

    <meta property="og:url" content="https://nextjs.org"/>

If we use any other (non empty, non-root) url, like this:

export const metadata: Metadata = {
  metadataBase: new URL('https://nextjs.org'),
  openGraph: {
    type: "website",
    url: "./page?utm=tracking",
    images: ["/images/og-image.png"],
  },
}

it works as expected:

    <meta property="og:url" content="https://nextjs.org/page?utm=tracking"/>

Current vs. Expected behavior

expecting the url parameters passed into openGraph Metadata to be preserved.
Alternatively the behaviour should be consistent (and url params dropped for other urls as well) but I doubt that's desirable

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.1.0: Thu Oct 10 21:02:45 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T8112
  Available memory (MB): 8192
  Available CPU cores: 8
Binaries:
  Node: 22.9.0
  npm: 10.8.3
  Yarn: N/A
  pnpm: 9.12.2
Relevant Packages:
  next: 15.2.0-canary.2 // Latest available version is detected (15.2.0-canary.2).
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.7.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Metadata

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local), Vercel (Deployed)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    MetadataRelated to Next.js' Metadata API.locked

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions