vercel / next.js

The React Framework
https://nextjs.org
MIT License
126.95k stars 26.98k forks source link

Docs: Generating a sitemap with `next export` #70670

Open alextse opened 1 month ago

alextse commented 1 month ago

What is the documentation issue?

Using the provided example, getting the following error with a SSG setup.

Error: Page "/sitemap.xml/[[...__metadata_id__]]/route" is missing exported function "generateStaticParams()", which is required with "output: export" config.

Is there any context that might help us understand?

Next.js version: 14.2.13

Is generating sitemap.xml even possible with SSG?

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

https://nextjs.org/docs/app/api-reference/file-conventions/metadata/sitemap

samcx commented 1 month ago

@alextse Can you clarify which example you're referring to (e.g., screenshot)?

alextse commented 1 month ago

Hi @samcx , below is the sample I've tried.

import type { MetadataRoute } from 'next'

export default function sitemap(): MetadataRoute.Sitemap {
  return [
    {
      url: 'https://acme.com',
      lastModified: new Date(),
      changeFrequency: 'yearly',
      priority: 1,
    },
    {
      url: 'https://acme.com/about',
      lastModified: new Date(),
      changeFrequency: 'monthly',
      priority: 0.8,
    },
    {
      url: 'https://acme.com/blog',
      lastModified: new Date(),
      changeFrequency: 'weekly',
      priority: 0.5,
    },
  ]
}

and here's my next.js config.

/** @type {import('next').NextConfig} */
const nextConfig = {
    output: 'export'
};

export default nextConfig;
samcx commented 1 month ago

@alextse Thanks for the clarification! Taking a look :frog-eyes:

fosple commented 2 weeks ago

Can also confirm the issue

Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote 👍 on the issue description or subscribe to the issue for updates. Thanks!