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

Canonical link doesn't accept search params on root path #65776

Open
ioancruso opened this issue May 15, 2024 · 0 comments
Open

Canonical link doesn't accept search params on root path #65776

ioancruso opened this issue May 15, 2024 · 0 comments
Labels
bug Issue was opened via the bug report template. Metadata Related to Next.js' Metadata API.

Comments

@ioancruso
Copy link

Link to the code that reproduces this issue

https://codesandbox.io/p/github/ioancruso/nextjs-bug-reproduction/main

To Reproduce

  1. Start the aplication
  2. Go to main page and press the button to go to a random page.
  3. Check the link tag with rel="canonical"

Current vs. Expected behavior

Since I've set the metadataBase URL in the layout and specified the path in the page file, the link should include the path along with the search parameters I've set, but it doesn't happen. It only displays the default metadataBase URL. This issue arises only when the path contains search parameters (e.g., "?something=something"). The strange thing is that it only occurs on the root path ("/"). I've included another page in a folder, and there the path is shown correctly.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
  Available memory (MB): 4102
  Available CPU cores: 2
Binaries:
  Node: 20.12.0
  npm: 10.5.0
  Yarn: 1.22.19
  pnpm: 8.15.6
Relevant Packages:
  next: 14.3.0-canary.63 // Latest available version is detected (14.3.0-canary.63).
  eslint-config-next: N/A
  react: 19.0.0-beta-4508873393-20240430
  react-dom: 19.0.0-beta-4508873393-20240430
  typescript: 5.1.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

@ioancruso ioancruso added the bug Issue was opened via the bug report template. label May 15, 2024
@github-actions github-actions bot added the Metadata Related to Next.js' Metadata API. label May 15, 2024
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