Next.js Discord

Discord Forum

Nextjs 14 why my dynamic sitemap.xml not working?

Unanswered
Thrianta posted this in #help-forum
Open in Discord
ThriantaOP
According to nextjs docs I crate an sitemap.js file inside my app directory for crate an dynamic sitemap but when I go http://localhost:3000/sitemap.xml I see 404 not found

enter image description here

here my code

app
sitemap.js


export default function 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,
    },
  ]
}

but when I crate an sitemap.xml inside my app directory I can see only static content not getting any content from sitemap.js

3 Replies