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

The property exclude VS generate:route priority #74

Closed
Aylay opened this issue Aug 5, 2019 — with CMTY · 3 comments

Comments

Copy link

commented Aug 5, 2019 — with CMTY

What problem does this feature solve?

Hi all ;)

In my nuxt file, I have an array of URL in generate:routes which contain multiple url and my 404 URL.
Also, I put this same 404 URL in the array of sitemap:exclude.

But, the 404 URL is always in my sitemap.xml.

Is it possible to force the exclude property of the generate sitemap property ?

Thanks

What does the proposed changes look like?

If any URL is in the exclude property and the generate:routes property, keep removing the URL in the exclude property

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

@cmty cmty bot added the cmty:feature-request label Aug 5, 2019

This comment has been minimized.

Copy link
Member

commented Aug 7, 2019 — with CMTY

Hi @Aylay

I'm not sure I understand your feature request.
According to your comment, it seems a bug on the exclude option

The sitemap module doesn't properly exclude your route 404, right?

if so, can you provide a sample of code (or, even better, a github project ^^) to reproduce your issue, please?

@Aylay

This comment has been minimized.

Copy link
Author

commented Aug 7, 2019

Hi @NicoPennec ,

You're totally right :)

My project is on Bitbucket ;)

Here is some code in my nuxt.config.js :

module.exports = {
  modules: [
    '@nuxtjs/pwa',
    '@nuxtjs/sitemap'
  ],
  generate: {
    routes: [
      '/404',
      '/pause-cafe/creation-developpement-site-internet',
      '/pause-cafe/objectifs-publicites-facebook'
    ]
  },
  sitemap: {
    hostname: appURL,
    gzip: true,
    exclude: [
      '/merci',
      '/404',
      '404'
    ]
  }
}

Is there an order putting module in the file ?

The first url in my sitemap.xml is /404 ;)

Thanks

This comment has been minimized.

Copy link
Member

commented Aug 11, 2019 — with CMTY

The sitemap.exclude option is only for static routes (see https://github.com/nuxt-community/sitemap-module/#exclude-optional)

Furthermore, If you don't set the sitemap.routes option for dynamic routes, the sitemap-module will initialize the value by default with the generate.routes value (see https://github.com/nuxt-community/sitemap-module/#routes)

So, the simple way to solve your issue is to init the sitemap.routes option with the requested routes.

eg.

module.exports = {
  modules: [
    '@nuxtjs/pwa',
    '@nuxtjs/sitemap'
  ],
  generate: {
    routes: [
      '/404',
      '/pause-cafe/creation-developpement-site-internet',
      '/pause-cafe/objectifs-publicites-facebook'
    ]
  },
  sitemap: {
    hostname: appURL,
    gzip: true,
    exclude: [
      '/merci'
    ],
    routes: [
      '/pause-cafe/creation-developpement-site-internet',
      '/pause-cafe/objectifs-publicites-facebook'
    ]
  }
}

Another way is to use the sitemap.filter option to exclude the "/404/" path

eg.

{
  sitemap: {
    filter ({ routes }) {
      return routes.filter(route => route.url !== '/404')
    }
  }
}

@NicoPennec NicoPennec closed this Aug 22, 2019

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