Sitemap is not available with nuxt/sitemap & nuxt/i18n module
See original GitHub issueI’m struggling making the sitemaps work with having the nuxt/sitemap and i18n module enabled.
This is my i18n configuration:
export default {
locales: supportedLanguages,
defaultLocale: 'ch-de',
strategy: 'prefix',
seo: false,
lazy: true,
langDir: 'lang/',
parsePages: false,
pages: computedRoutes,
vueI18n: {
fallbackLocale: 'ch-de'
},
detectBrowserLanguage: {
useCookie: true,
cookieKey: 'i18n_redirected',
alwaysRedirect: false,
fallbackLocale: 'ch-de',
onlyOnRoot: true
}
}
and here is my sitemap config fron the nuxt.config.js:
sitemap: {
hostname: 'https://someurl.com',
exclude: ['/**'],
sitemaps: [
{
path: '/sitemap.xml',
exclude: ['/**'],
routes() {
return getRoutesFor('keypersons')
},
gzip: false
}
]
}
what i found out is that the generated sitemap-routes.json is not included when deploying with this builder… so i added the file to the serverFiles
array in my vercel.json.
"serverFiles": [
"lang/**",
"config/**",
"sitemap/**",
".nuxt/dist/sitemap-routes.json"
]
With my sitemap configuration i assume that the sitemap.xml would be under https://someurl.com/sitemap.xml but i first get redirected to someurl.com/ch-de/sitemap.xml and than i get a 404 on that page.
I also tried to adjust things in the i18n config but i just can’t make it work. I have to use the i18n prefix
strategy because i want all urls to be prefixed with the language.
Locally when i start nuxt in server
mode everything works fine.
Did someone have the same Issue? or is thins a known problem?
Issue Analytics
- State:
- Created 3 years ago
- Comments:18 (5 by maintainers)
Top GitHub Comments
@andrew-boyd Your solution works for me! I had
async routes()
function in my configuration. I wrapped everything inexport default async
function and now it works like a charm! Thank you.@danielroe see #516