Skip to content

Cannot create app router localized sitemap #67005

@arvinpoddar

Description

@arvinpoddar

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/elastic-wave-5d4hkj?workspaceId=b7d16bab-058a-4b6f-b4f8-cb3182273009

To Reproduce

  1. Create a new Next.js app with npx create-next-app@latest (accept all the default settings)
  2. Create a new app/sitemap.ts file
  3. Copy and paste the example from: https://nextjs.org/docs/app/api-reference/file-conventions/metadata/sitemap#generating-a-sitemap-using-code-js-ts. This will work when you visit localhost:3000/sitemap.xml
  4. Now, copy and paste the localized example: https://nextjs.org/docs/app/api-reference/file-conventions/metadata/sitemap#generate-a-localized-sitemap. This will not work. Remove all the alternates, and it works again.

Current vs. Expected behavior

We would expect to see a sitemap with localized alternates when we visit localhost:3000/sitemap.xml. Instead, visiting this route results in a plain text result, with a Uncaught TypeError: Cannot read properties of null (reading 'childNodes') error in the browser console.

CleanShot 2024-06-18 at 21 40 33

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.9.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 15.0.0-canary.37 // Latest available version is detected (15.0.0-canary.37).
  eslint-config-next: N/A
  react: 19.0.0-rc-6f23540c7d-20240528
  react-dom: 19.0.0-rc-6f23540c7d-20240528
  typescript: 5.3.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)

Additional context

This issue is a duplicate of: #65817

Metadata

Metadata

Assignees

No one assigned

    Labels

    MetadataRelated to Next.js' Metadata API.linear: nextConfirmed issue that is tracked by the Next.js team.locked

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions