question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sitemap is not available with nuxt/sitemap & nuxt/i18n module

See original GitHub issue

I’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 serverFilesarray 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:closed
  • Created 3 years ago
  • Comments:18 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
levz0rcommented, Jan 5, 2021

@andrew-boyd Your solution works for me! I had async routes() function in my configuration. I wrapped everything in export default async function and now it works like a charm! Thank you.

2reactions
selfagencycommented, Feb 23, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Sitemap options - Nuxt Sitemap Module
Sitemap options module. ... This option is only available in ssr mode. ... Configure the support of localized routes from nuxt-i18n module.
Read more >
nuxt sitemap not working properly when used with nuxt-i18n
It's only a rendering issue on your browser, due to the xml namespace of the elements <xhtml:link> . Your browser will convert the...
Read more >
@nuxtjs/sitemap NPM | npm.io
Automatically generate or serve dynamic sitemap.xml for Nuxt.js projects! Release Notes. Features. Module based on the awesome sitemap.js package ❤️ ...
Read more >
Working With Sitemaps in Nuxt.js - DEV Community ‍ ‍
Create a sitemap of routes, pages, and dynamic routes Photo by Nik ... If you use nuxt-i18n and your app has several domains,...
Read more >
Sitemap.xml on a Nuxt site - Issues - Edgio Community Forums
From the nuxt sitemap example docs, and see the same behavior on the XDN: ... It's likely the issue is there was not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found