Search code examples
gatsbysitemap

gatsby-plugin-sitemap not excluding nested folders


I created the excludes array for gatsby-plugin-sitemap in my gatsby-config.js file; however, if there are nested folders, they aren't excluded. (FYI, I did a clean and then a build followed by a serve every time).

Here is my example:

    {
      resolve: 'gatsby-plugin-sitemap',
      options: {
        output: '/',
        excludes: [
          `/404/`,
          `/thanks`,
          `/screens/*`,
          `/screens/resources/*`,
        ],
      },
    },

If in the /screens/resources/ folder, there is only a file, it works. If, however, there is another folder, like /screens/resources/sections/, those pages will appear in the sitemap.

Am I doing something incorrectly? Is there a way to exclude everything in the /screens/ folder? I tried /screens/* and /screens* but nothing works if there are nested folders in the screens folder.

Thanks in advance for any assistance you might be able to give me.


Solution

  • I think you miss the only workaround which may work:

    {
      resolve: 'gatsby-plugin-sitemap',
      options: {
        output: '/',
        excludes: [
          `/404/`,
          `/thanks`,
          `/screens/**`,
        ],
      },
    },
    

    It seems that the plugin works with a minimatch but it's not documented.