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

alternates metadata are not correctly merged #74361

Open
axeleroy opened this issue Dec 29, 2024 · 2 comments
Open

alternates metadata are not correctly merged #74361

axeleroy opened this issue Dec 29, 2024 · 2 comments
Labels
bug Issue was opened via the bug report template. Metadata Related to Next.js' Metadata API.

Comments

@axeleroy
Copy link

Link to the code that reproduces this issue

https://github.com/axeleroy/nextjs-alternates-repro

To Reproduce

  1. Start the dev server
  2. Navigate to http://localhost:3000
  3. Inspect the page. The alternates are
<link rel="alternate" hrefLang="en-US" href="https://nextjs.org/en-US"/>
<link rel="alternate" hrefLang="de-DE" href="https://nextjs.org/de-DE"/>
  1. Navigate to http://localhost:3000/sub-page-1
  2. Inspect the page. The alternates are
<link rel="alternate" type="application/rss+xml" href="https://example.tld/feed.xml"/>
  1. Navigate to http://localhost:3000/sub-page-1
  2. Inspect the page. The alternates are
<link rel="canonical" href="https://example.tld/sub-page-2"/>

Current vs. Expected behavior

  1. Start the dev server
  2. Navigate to http://localhost:3000
  3. Inspect the page. The alternates should be
<link rel="alternate" type="application/rss+xml" href="https://example.tld/feed.xml"/>
<link rel="alternate" hrefLang="en-US" href="https://nextjs.org/en-US"/>
<link rel="alternate" hrefLang="de-DE" href="https://nextjs.org/de-DE"/>

instead of

<link rel="alternate" hrefLang="en-US" href="https://nextjs.org/en-US"/>
<link rel="alternate" hrefLang="de-DE" href="https://nextjs.org/de-DE"/>
  1. Navigate to http://localhost:3000/sub-page-1
  2. Inspect the page. The alternates are
<link rel="alternate" type="application/rss+xml" href="https://example.tld/feed.xml"/>
  1. Navigate to http://localhost:3000/sub-page-1
  2. Inspect the page. The alternates should be
<link rel="alternate" type="application/rss+xml" href="https://example.tld/feed.xml"/>
<link rel="canonical" href="https://example.tld/sub-page-2"/>

instead of

<link rel="canonical" href="https://example.tld/sub-page-2"/>

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #51-Ubuntu SMP PREEMPT_DYNAMIC Sat Nov  9 17:58:29 UTC 2024
  Available memory (MB): 7680
  Available CPU cores: 8
Binaries:
  Node: 20.12.2
  npm: 10.5.0
  Yarn: 1.9.4
  pnpm: 8.15.4
Relevant Packages:
  next: 15.1.3 // Latest available version is detected (15.1.3).
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.7.2
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), Other (Deployed)

Additional context

In addition to the stages mentioned above, I have also noted that the issue happens regardless of whether Turbo is used or not and on Static HTML exports.

@axeleroy axeleroy added the bug Issue was opened via the bug report template. label Dec 29, 2024
@github-actions github-actions bot added the Metadata Related to Next.js' Metadata API. label Dec 29, 2024
@AliRazaDev27
Copy link

Read the docs.
https://nextjs.org/docs/app/building-your-application/optimizing/metadata#merging
image
see how the description field from layout is not merged into page metadata.

@axeleroy
Copy link
Author

Oh right, I missed that. Maybe the docs should emphasize this part, for example by putting "Note the absence of openGraph.description" in bold?

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

2 participants