Version
v1.0.0
Reproduction link
https://alexanderbarton.de/sitemap.xml
Steps to reproduce
Just generate the sitemap with the config. :)
What is expected ?
Routes in sitemap without the /_nuxt/ prefix
What is actually happening?
Routes in sitemap with /_nuxt/ prefix
Additional comments?
This is my nuxt.config.js:
const pkg = require('./package');
const dotenv = require('dotenv');
dotenv.config();
module.exports = {
mode: 'universal',
/*
** Headers of the page
*/
head: {
title: pkg.name,
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: pkg.description }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
]
},
/*
** Customize the progress-bar color
*/
loading: false,
/*
** Global CSS
*/
css: [
'~assets/scss/style.scss',
],
/*
** Plugins to load before mounting the App
*/
plugins: [
{src: '~plugins/bootstrap-native', ssr: false},
{src: '~plugins/tiny-slider', ssr: false}
],
/*
** Nuxt.js modules
*/
modules: [
'@nuxtjs/dotenv',
'@nuxtjs/axios',
'@nuxtjs/redirect-module',
['@nuxtjs/google-tag-manager', {
id: process.env.GTMCONTAINERID
}],
['nuxt-i18n', {
strategy: 'prefixexceptdefault',
defaultLocale: 'de',
lazy: true,
langDir: 'translations/',
locales: [
{
code: 'de',
file: 'de.json'
}
],
}],
'@nuxtjs/sitemap'
],
axios: {
// proxyHeaders: false
},
redirect: [
{ from: '^/datenschutz-erklaerung', to: '/datenschutz' }
],
/*
** Build configuration
*/
build: {
extend(config) {
config.module.rules.push({
test: /bootstrap.native/,
use: {
loader: 'bootstrap.native-loader',
options: {
only: ['collapse', 'modal']
}
}
});
}
}
};
Can you give more details?
Nuxt.js
versionnode.js
versionyarn generate
or yarn build && yarn start
)Do you confirm that your sitemap config is empty?
Then, can you removed or disabled the other modules and retry?
To fix your issue quickly, you may use the following workaround:
```js
{
sitemap: {
filter ({ routes }) {
return routes.map(route => route.url = route.url.replace("/_nuxt", ""))
}
}
}
@AlexBa Ok, I reproduce when the sitemap: {}
configuration object is missing.
@AlexBa for now the better way to fix your issue is to explicitly set the hostname
option in your nuxt.config.js
file:
{
sitemap: {
hostname: "https://alexanderbarton.de"
}
}
I will check to improve your use case.
@NicoPennec This code seems to work:
{
sitemap: {
hostname: "https://alexanderbarton.de"
}
}
But this code doesn't work (I have tried it before):
{
sitemap: {
filter ({ routes }) {
return routes.map(route => route.url = route.url.replace("/_nuxt", ""))
}
}
}
The commands, I tried, were: nuxt
and nuxt generate
I just want to provide you some missing info. Maybe it can be helpful for later:
Thank you for your help!
Thanks for your answer with all details, but as explain before your last post, I found the issue.
It should be fixed since the release v1.1.0, see CHANGELOG
Please update your @nuxtjs/sitemap
dependency to the latest release, remove your config `sitemap: { … } as before, and retry to generate the sitemap.
I experienced this issue when installing the module, adding to the end of my modules: [] without any further configuration.
When looking at the sitemap on my local machine, it was fine; but when deployed it contained /_nuxt/ for each route.
In my case it was actually worse, as I was using a CDN as a publicpath, so the path actually pointed to a _nuxt route on my CDN endpoint.
I was also using i18n with several languages.
Can confirm that adding a sitemap: {
hostname: "https://cmpct.io"
}
fixed the issue as described in this issue.
I was on version 2.0.1
@tommcclean I need more details to reproduce the issue
nuxt.config.js
?build: { publicPath: "..." }
on production in your nuxt.config.js
?
Please note, that I can't report a bug with cmty.app, because there is no version to select in the sitemap module, but this field is required.