Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
CodingFabian opened this issue Jan 9, 2025 · 0 comments
Open
Labels
bug Issue was opened via the bug report template. Metadata Related to Next.js' Metadata API.

Comments

@CodingFabian
Copy link

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

@CodingFabian CodingFabian added the bug Issue was opened via the bug report template. label Jan 9, 2025
@github-actions github-actions bot added the Metadata Related to Next.js' Metadata API. label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Metadata Related to Next.js' Metadata API.
Projects
None yet
Development

No branches or pull requests

1 participant