nextjs - 💡(How to fix) Fix [Bug] Sitemap renders as HTML instead of XML when alternates are enabled [4 comments, 4 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#86248Fetched 2026-04-08 02:11:54
View on GitHub
Comments
4
Participants
4
Timeline
9
Reactions
0
Author
Timeline (top)
commented ×4labeled ×2closed ×1issue_type_added ×1

Code Example

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 12244
  Available CPU cores: 8
Binaries:
  Node: 24.11.1
  npm: 11.6.2
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.0.2-canary.23 // Latest available version is detected (16.0.2-canary.23).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/bennajah/next-i18n

To Reproduce

  1. go to app/sitemap.ts
  2. set enableAlternate to true and visit http://localhost:3000/sitemap.xml you see this
<img width="742" height="568" alt="Image" src="https://github.com/user-attachments/assets/f04eec9d-331d-4320-95b3-cabfa443fba9" />
  1. set back enableAlternate to false and visit http://localhost:3000/sitemap.xml you see this
<img width="857" height="360" alt="Image" src="https://github.com/user-attachments/assets/15d2441c-6504-4eac-b965-2e72b9319c0c" />

Current vs. Expected behavior

enabling the alternates option inside the sitemap.ts configuration causes the generated sitemap.xml to render as an HTML document instead of a valid XML sitemap.

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 12244
  Available CPU cores: 8
Binaries:
  Node: 24.11.1
  npm: 11.6.2
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.0.2-canary.23 // Latest available version is detected (16.0.2-canary.23).
  eslint-config-next: N/A
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
Next.js Config:
  output: N/A

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

Internationalization (i18n)

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

next dev (local), next build (local)

Additional context

No response

extent analysis

TL;DR

  • Setting enableAlternate to true in app/sitemap.ts may require additional configuration to correctly generate a valid XML sitemap.

Guidance

  • Review the app/sitemap.ts configuration to ensure that the enableAlternate option is correctly implemented and compatible with the current Next.js version (16.0.2-canary.23).
  • Verify that the XML sitemap is being generated correctly when enableAlternate is set to false, and compare the differences in the generated sitemap when the option is set to true.
  • Check the Next.js documentation and the next-i18n library documentation for any specific requirements or guidelines for implementing the enableAlternate option.
  • Consider testing the sitemap generation with different configurations to isolate the issue and identify any potential workarounds.

Notes

  • The issue may be specific to the next-i18n library or the current Next.js version, so it's essential to review the documentation and any related issues or pull requests.
  • Without more information about the app/sitemap.ts configuration and the expected behavior, it's challenging to provide a more specific solution.

Recommendation

  • Apply workaround: Try setting enableAlternate to false or experiment with different configurations to find a working solution, as the root cause of the issue is unclear.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING