Search code examples
vue.jsnuxt.jsseo

nuxt-sitemap does not find pre-rendered pages


The sitemap I am trying to build is not finding the blog pages that are dynamically rendered.

What I am doing:

yarn build // running nuxi build
node .output/server/index.mjs

My setup:

nuxt: ^3.10.2, @nuxtjs/sitemap: ^5.1.0

Blog Posts are displayed, fetching happens through apollo in one of my components:

const { data, pending } = await useAsyncQuery(getPosts, { size: numArticlesPerPage, offset: offset.value })

Also, according to the docs I added to my nuxt.config.ts:

nitro: {
    prerender: {
      crawlLinks: true,
      routes: ["/", "/blog"], // I also tried adding the sitemap file here directly
    },
  },

What is happening:

  • sitemap is being generated of all pages in my /pages directory
  • prerender output shows all the necessary blog pages such as /blog/article-x, /blog/article/y being rendered. Blog pages are also visible on server
  • in the sitemap none of those blog posts are being shown

Solution

  • You need to add an API source for nuxt sitemap to generate the pages.