sitemap.xml not generating

crabdul
0
crabdul
commented 2 years ago

The sitemap is not running when I run the build command.

Below is the configuration for modules and sitemap.
I am importing axios at the start of the nuxt.config.js file

  modules: ['@nuxtjs/sitemap'],
  sitemap: {
    hostname: 'https://karaimusic.com',
    routes () {
      return axios.get('https://karaimusic.co.uk/wp-json/wp/v2/posts?categories=2')
        .then(res => res.data.map(track => {
          const path = '/tracks/' + track.slug
          console.log(path)
          return path
        }))
    }
  }

Axios is getting the data properly because I'm able to print out the slugs of my posts properly

/tracks/parquet-courts-almost-had-to-start-a-fight-in-and-out-of-patience
/tracks/iceage-catch-it

Where am I going wrong?
What else can I check?

0
NicoPennec
1.4k
NicoPennec
commented 2 years ago

@crabdul, I have tried your use case, it works fine for me!

My steps to reproduce:

// starting from an empty project with Nuxt.js 1.4.0 from starter-template

$ npm install @nuxtjs/sitemap
$ npm install axios

// edit the nuxt.config.json with your configuration,
// add on top `const axios = require('axios')`

$ npm run build
$ npm run start

// open http://localhost:3000/sitemap.xml
0
crabdul
0
crabdul
commented 2 years ago

Thank you for your help!

I assumed it wasn't generating the sitemap because the sitemap.xml file doesn't appear in .nuxt when I run the build command

0
amjadkhan896
0
amjadkhan896
commented 7 months ago

is it possible to make one sitemap file and in that file, we include 5 sitemaps other files?
Like I want to divide the big sitemap file into smaller 2 or 3 files,
Because my links combination are crossing more than 50 or 60k

0
amjadkhan896
0
amjadkhan896
commented 7 months ago

@crabdul did you fixed the issue, did you put the modification date and frequency while using the axios request. I am also stuck

0
Informations
Question โ€ข Unresolved
#c11 - Created 2 years ago