Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Localized sitemaps (using nuxt-i18n) #32

Closed
SnirShechter opened this issue Oct 2, 2018 — with CMTY · 7 comments

Comments

Projects
None yet
6 participants
Copy link

commented Oct 2, 2018 — with CMTY

What problem does this feature solve?

There is no way of automatically generating a sitemap when the site is localized (using nuxt-i18n, for example).

Two difficulties when using the sitemap module with the nuxt-i18n localization:

  1. Prefixes ('/en').
  2. Url localization (/en/shop becomes /fr/boutique or so).

What does the proposed changes look like?

I suggest (if in any way possible) to generate the static pages using the router routes after they were already generated by the nuxt-i18n module.

This feature request is available on Nuxt community (#c31)

@cmty cmty bot added the cmty:feature-request label Oct 2, 2018

@thariddler

This comment has been minimized.

Copy link

commented Nov 15, 2018

I am looking for the same feature. Pretty frustrating that it's missing.

@thariddler

This comment has been minimized.

Copy link

commented Nov 15, 2018

Ideally if nuxt-i18n is return all urls that we can then use.

@Kinvaras

This comment has been minimized.

Copy link

commented Nov 21, 2018

Hi,

I had the same problem recently, in a project using nuxt-i18n. The problem is the sitemap module doesn't take care of dynamically generated routes in a localized context. With no extra options for the nuxt sitemap module in nuxt.config.js, my sitemap was well defined. But adding a simple option to the module broke the generation up. Actually, it seems like module declaration order in your nuxt.config.js is important.

You have to inject it after the i18n nuxt module.

For example:

// nuxt.config.js

module.exports = {
// ...
  modules: [
    '@nuxtjs/sitemap',
    [
      'nuxt-i18n',
      require('./config/i18n'),
    ],
  ],
  sitemap: require('./config/sitemap'),
// ...
}

With the following "config/sitemap.js", it works as expected:

// config/sitemap.js

module.exports = {};

While it doesn't with the following:

// config/sitemap.js

module.exports = {
  path: '/sitemap.xml',
  hostname: process.env.BASE_URL,
  exclude: [
    '/en/**',
    '/es/**',
  ],
};

But if you inject the sitemap module like this:

// nuxt.config.js

module.exports = {
// ...
  modules: [
    [
      'nuxt-i18n',
      require('./config/i18n'),
    ],
    '@nuxtjs/sitemap', // Notice the order
  ],
  sitemap: require('./config/sitemap'),
// ...
}

It works in both case !
Tell me if it solves your problem or if I misunderstood your issue.

Cheers

@NicoPennec

This comment has been minimized.

Copy link
Member

commented Jan 8, 2019

@Kinvaras thank you for your help 🙏

@NicoPennec NicoPennec closed this in eefc7a6 Jan 8, 2019

NicoPennec added a commit that referenced this issue Apr 15, 2019

doc: update README
add an instruction about the declaration order of sitemap module with other nuxt modules (eg. nuxt-i18n)

fix #32
@HapLifeMan

This comment has been minimized.

Copy link

commented Apr 19, 2019

It can be very interesting if an option can generate different sitemap files for every locale, maybe by defining an array for each sitemap or directly integrated with i18n.

Then we can reference these files in the robots.txt 🙂

@bdrtsky

This comment has been minimized.

Copy link

commented Apr 23, 2019

As far I as I know this module doesnt not support multiple sitemaps?

@NicoPennec

This comment has been minimized.

Copy link
Member

commented Apr 23, 2019

@bdrtsky not yet, but in the roadmap in short term

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.