Sitemap from `gatsby-plugin-advanced-sitemap` excludes `/`

Thanks for getting back so quickly, @DavidDarnes.

Project Setup

Do you have any specific settings or a particular setup to your project?

I have a very straight-forward project setup with "gatsby": "^2.15.14" and "gatsby-plugin-advanced-sitemap": "^1.4.4". Just a handful of plugins, with 5 routes from the pages directory that I want in the sitemap. Included in these 5 desired sitemap entries is the the / route for my index.js page.

Things I’ve Tried

I was using this plugin without any config at first, but after noticing that:

  • there are routes in the sitemap that I don’t want to include, and
  • the / route is excluded from sitemap-pages.xml

I tried the following config after testing the allSitePage query in GraphiQL:

...
{
  resolve: `gatsby-plugin-advanced-sitemap`,
  options: {
    query: `
    {
      allSitePage {
        edges {
          node {
            path
            slug: path
            url: path
          }
        }
      }
    }
    `,
    mapping: {
      allSitePage: {
        sitemap: `pages`,
      },
    },
    exclude: [
      `/dev-404-page`,
      `/404`,
      `/404.html`,
      `/account`,
      `/assets`,
      `/loading`,
      `/offline-plugin-app-shell-fallback`,
    ],
    createLinkInHead: true, // optional: create a link in the `<head>` of your site
    addUncaughtPages: true, // optional: will fill up pages that are not caught by queries and mapping and list them under `sitemap-pages.xml`
  },
},
...

The resulting sitemap-pages.xml does include the / route, but it removes all of the other routes aside from /pricing, which is the alphabetically-last route.

I don’t know how the plugin works, but to me it seems like maybe an array of the routes returned by allSitePage is being iterated over, returning a single value that keeps being overwritten.

The Goal

Since I want to exclude some routes from my sitemap, getting the plugin working with the config would be my top priority (in my case, working = a sitemap with /, /pricing, and the 3 missing routes). But the problem remains that the / route for pages/index.js isn’t included without a special config. I can’t share the repository for this project (monorepo w/backend IP), but I’m happy to provide any information about the gatsby setup I’m using.