Skip to content

Docs: localized sitemap example is broken #63764

@FelDev

Description

@FelDev

What is the improvement or update you wish to see?

https://nextjs.org/docs/app/api-reference/file-conventions/metadata/sitemap#generate-a-localized-sitemap

The localized sitemap example looks like this

import { MetadataRoute } from 'next'
 
export default function sitemap(): MetadataRoute.Sitemap {
  return [
    {
      url: 'https://acme.com',
      lastModified: new Date(),
      alternates: {
        languages: {
          es: 'https://acme.com/es',
          de: 'https://acme.com/de',
        },
      },
    },
    {
      url: 'https://acme.com/about',
      lastModified: new Date(),
      alternates: {
        languages: {
          es: 'https://acme.com/es/about',
          de: 'https://acme.com/de/about',
        },
      },
    },
    {
      url: 'https://acme.com/blog',
      lastModified: new Date(),
      alternates: {
        languages: {
          es: 'https://acme.com/es/blog',
          de: 'https://acme.com/de/blog',
        },
      },
    },
  ]
}

If I copy paste that example, it doesn't work.

Object literal may only specify known properties, and 'alternates' does not exist in type '{ url: string; lastModified?: string | Date | undefined; changeFrequency?: "always" | "hourly" | "daily" | "weekly" | "monthly" | "yearly" | "never" | undefined; priority?: number | undefined; }'
Screenshot 2024-03-27 at 09 34 36

Also, when selecting "javascript" instead of "typescript", the example disapears.

Screenshot 2024-03-27 at 09 36 20

Is there any context that might help us understand?

I literally copy pasted the example from the docs.

Does the docs page already exist? Please link to it.

https://nextjs.org/docs/app/api-reference/file-conventions/metadata/sitemap#generate-a-localized-sitemap

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationRelated to Next.js' official documentation.locked

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions