Link to the code that reproduces this issue
https://github.com/axeleroy/nextjs-alternates-repro
To Reproduce
- Start the dev server
- Navigate to http://localhost:3000
- 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"/>
- Navigate to http://localhost:3000/sub-page-1
- Inspect the page. The alternates are
<link rel="alternate" type="application/rss+xml" href="https://example.tld/feed.xml"/>
- Navigate to http://localhost:3000/sub-page-1
- Inspect the page. The alternates are
<link rel="canonical" href="https://example.tld/sub-page-2"/>
Current vs. Expected behavior
- Start the dev server
- Navigate to http://localhost:3000
- 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"/>
- Navigate to http://localhost:3000/sub-page-1
- Inspect the page. The alternates are
<link rel="alternate" type="application/rss+xml" href="https://example.tld/feed.xml"/>
- Navigate to http://localhost:3000/sub-page-1
- 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.
Link to the code that reproduces this issue
https://github.com/axeleroy/nextjs-alternates-repro
To Reproduce
Current vs. Expected behavior
instead of
instead of
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/AWhich 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.