nextjs - 💡(How to fix) Fix Duplicate page detected. `app/sitemap.ts` and `app/sitemap.xml/route.ts` resolve to `/sitemap.xml` [1 comments, 2 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#87313Fetched 2026-04-08 02:07:16
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×2closed ×1commented ×1issue_type_added ×1

Error Message

  1. See the console error:

Code Example

Duplicate page detected. app/sitemap.ts and app/sitemap.xml/route.ts resolve to /sitemap.xml

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.1.0: Mon Oct 20 19:32:41 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 22.18.0
  npm: 11.6.0
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.0.10 // Latest available version is detected (16.0.10).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/quizzical-tom-c6383d?workspaceId=ws_4bYFShiWoNEitzjMUdiwwM

To Reproduce

  1. Start the application in development (next dev)
  2. See the console error:
 ⚠ Duplicate page detected. app/sitemap.ts and app/sitemap.xml/route.ts resolve to /sitemap.xml

Current vs. Expected behavior

When using the generateSitemaps functionality to generate multiple sitemaps for you app, you can't use the sitemap.xml/route.ts at the same time.

There'll be a route collision even though the app/sitemap.ts doesn't generate a sitemap.xml file (only sitemap/[id].xml files).

I'd imagine being able to generate multiple sitemaps using the generateSitemaps and create a separate sitemap.xml file for sitemap index.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.1.0: Mon Oct 20 19:32:41 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 22.18.0
  npm: 11.6.0
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.0.10 // Latest available version is detected (16.0.10).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.9.3
Next.js Config:
  output: N/A

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

Route Handlers

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

next dev (local)

Additional context

No response

extent analysis

TL;DR

Rename or reconfigure the app/sitemap.ts file to avoid route collision with sitemap.xml/route.ts.

Guidance

  • Verify that the app/sitemap.ts file is not generating a sitemap.xml file, but rather sitemap/[id].xml files, to understand the source of the route collision.
  • Consider renaming the app/sitemap.ts file to a different name, such as app/sitemaps.ts, to avoid the conflict with sitemap.xml/route.ts.
  • Review the generateSitemaps functionality to ensure it is correctly handling multiple sitemaps and not causing the route collision.
  • Check the Next.js routing configuration to see if there are any settings that can be adjusted to allow for multiple sitemaps without collisions.

Example

No code example is provided as the issue is related to configuration and routing, and the exact code changes would depend on the specific implementation.

Notes

The issue seems to be specific to the development environment (next dev) and may not affect production. However, resolving the issue will ensure that the generateSitemaps functionality works as expected.

Recommendation

Apply workaround: Rename the app/sitemap.ts file to avoid the route collision, as this is a simpler and more straightforward solution than reconfiguring the routing or generateSitemaps functionality.

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