Search code examples
nuxt.jssitemapnuxt-i18n

nuxt sitemap not working properly when used with nuxt-i18n


When setup the config for nuxt-i18n in nuxt sitemap config the sitemap is not rendering properly.

sitemap: {
     hostname: 'http://localhost:8080',
     cacheTime: 600000,
     gzip: true,
     i18n: {
       defaultLocale: 'en',
       routesNameSeparator: '___'
     }
},

This is the output of sitemap when enable i18n in the config. enter image description here

But when i18n is not used in the sitemap config

 sitemap: {
    hostname: 'http://localhost:8080',
    cacheTime: 600000,
    gzip: true
  },

This is the output of sitemap enter image description here

Since the project does have multilanguage so I need to setup the i18n config for the sitemap so that the sitemap could have alternate link of all the multilange as shown in the image below enter image description here


Solution

  • It's only a rendering issue on your browser, due to the xml namespace of the elements <xhtml:link>. Your browser will convert the XML rendering to a XHTML page rendering because it see a know "xhtml:*" namespace.

    Check the source code of the sitemap.xml, you will see that your XML file is correct.