Hi all ;)
In my nuxt file, I have an array of URL in generate:routes which contain multiple url and my 404 URL.
Also, I put this same 404 URL in the array of sitemap:exclude.
But, the 404 URL is always in my sitemap.xml.
Is it possible to force the exclude property of the generate sitemap property ?
Thanks
If any URL is in the exclude property and the generate:routes property, keep removing the URL in the exclude property
Hi @NicoPennec ,
You're totally right :)
My project is on Bitbucket ;)
Here is some code in my nuxt.config.js :
module.exports = {
modules: [
'@nuxtjs/pwa',
'@nuxtjs/sitemap'
],
generate: {
routes: [
'/404',
'/pause-cafe/creation-developpement-site-internet',
'/pause-cafe/objectifs-publicites-facebook'
]
},
sitemap: {
hostname: appURL,
gzip: true,
exclude: [
'/merci',
'/404',
'404'
]
}
}
Is there an order putting module in the file ?
The first url in my sitemap.xml is /404 ;)
Thanks
The sitemap.exclude
option is only for static routes (see https://github.com/nuxt-community/sitemap-module/#exclude-optional)
Furthermore, If you don't set the sitemap.routes
option for dynamic routes, the sitemap-module will initialize the value by default with the generate.routes
value (see https://github.com/nuxt-community/sitemap-module/#routes)
So, the simple way to solve your issue is to init the sitemap.routes
option with the requested routes.
eg.
module.exports = {
modules: [
'@nuxtjs/pwa',
'@nuxtjs/sitemap'
],
generate: {
routes: [
'/404',
'/pause-cafe/creation-developpement-site-internet',
'/pause-cafe/objectifs-publicites-facebook'
]
},
sitemap: {
hostname: appURL,
gzip: true,
exclude: [
'/merci'
],
routes: [
'/pause-cafe/creation-developpement-site-internet',
'/pause-cafe/objectifs-publicites-facebook'
]
}
}
Another way is to use the sitemap.filter
option to exclude the "/404/" path
eg.
{
sitemap: {
filter ({ routes }) {
return routes.filter(route => route.url !== '/404')
}
}
}
Hi @Aylay
I'm not sure I understand your feature request.
According to your comment, it seems a bug on the
exclude
optionThe sitemap module doesn't properly exclude your route 404, right?
if so, can you provide a sample of code (or, even better, a github project ^^) to reproduce your issue, please?