harlan-zw / nuxt-seo

The complete SEO solution for Nuxt.
https://nuxtseo.com
MIT License
1.09k stars 70 forks source link

Config added URLs are not in the generated sitemap.xml on build + preview #312

Closed ManuelTS closed 2 months ago

ManuelTS commented 2 months ago

Describe the bug

I have URLs with params and therefore I want to add some in the nuxt.config.ts#sitemap.urls as written in the docs, but they appear not in the sitemap.

Reproduction

When i run npm run dev everything is fine, but when I run npm run build with npm run preview the URLs from the config are missing in the generated sitemap.xml

System / Nuxt Info

Here the important parts of `nuxt.config.ts`:

  // ...
  compatibilityDate: '2024-08-04',
  ssr: true,
  nitro: {
    prerender: {
      crawlLinks: true,
      routes: ['/sitemap.xml', '/robots.txt']
    }
  },
  sitemap: {
    urls: [ // Absolute or relative does not matter, both do not appear in the final sitemap.xml
      'a',
      'a/06052023200153'
    ]
  },
  runtimeConfig: {
    public: {
      baseUrl: process.env.BASE_URL
    }
  },
  modules: [
    '@nuxtjs/i18n',
    '@nuxt/image',
    '@nuxtjs/sitemap',
    'nuxt-schema-org',
  ],
// ...

Dependencies from package.json:

  "dependencies": {
    "@nuxt/image": "1.7.0",
    "@nuxtjs/i18n": "8.3.3",
    "@nuxtjs/robots": "4.0.2",
    "@nuxtjs/sitemap": "5.3.5",
    "@vercel/postgres": "0.9.0",
    "nuxt": "3.12.4",
    "nuxt-schema-org": "3.3.9",
    "vue": "3.4.35",
    "vue-router": "4.4.2"
  },
  "devDependencies": {
    "sass": "1.77.8",
    "vercel": "35.2.3"
  },
  "engines": {
    "node": "20.16.0",
    "npm": "10.8.1"
  }
harlan-zw commented 2 months ago

Can you please provide a reproduction? https://nuxtseo.com/sitemap/getting-started/stackblitz

Also please prefix your paths with a / for them to be valid, may be the issue.

Seems fine here: https://stackblitz.com/edit/nuxt-starter-avc82i?file=nuxt.config.ts