Skip to content

'gatsby-plugin-sitemap' doesn't generate a /sitemap.xml file #31095

@mikeyfe6

Description

@mikeyfe6

Description

'gatsby-plugin-sitemap' doesn't generate a sitemap.xml file, even with default config.

I've changed to the default config of this plugin. In the past it worked like a charm with this code (beneath) but since gatsby-plugin-sitemap v4 it stopped working. Now even the default config doesn't show me the sitemap by going to 'yoursiteurl.com/sitemap.xml'.

{
      resolve: 'gatsby-plugin-sitemap',
      options: {
        query: `
        {
          site {
            siteMetadata {
              siteUrl
            }
          }

          allSitePage {
            edges {
              node {
                path
                context {
                  updatedAt
                }
              }
            }
          }
      }`,
        serialize: ({ site, allSitePage }) =>
          allSitePage.edges.map((edge) => ({
            url: `${site.siteMetadata.siteUrl}${edge.node.path}`,
            changefreq: 'daily',
            priority: 0.7,
            lastmodISO: edge.node.context.updatedAt,
          })),
      },
    },

or

plugins: [`gatsby-plugin-sitemap`]

The old config gives me serializing errors and the second (default) one gives me no sitemap, but goes to 404. What am i doing wrong??

Expected result

Sitemap should show up when I gatsby build && gatsby serve and go to localhost:9000/sitemap.xml ('localhost:9000/sitemap' isn't working either)

Actual result

No sitemap to be found...

Environment


  System:
    OS: macOS 11.3
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 15.14.0 - ~/.nvm/versions/node/v15.14.0/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.11.1 - ~/.nvm/versions/node/v15.14.0/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 90.0.4430.93
    Safari: 14.1
  npmPackages:
    gatsby: ^3.4.0 => 3.4.0 
    gatsby-plugin-canonical-urls: ^3.4.0 => 3.4.0 
    gatsby-plugin-catch-links: ^3.4.0 => 3.4.0 
    gatsby-plugin-eslint: ^3.0.0 => 3.0.0 
    gatsby-plugin-feed: ^3.4.0 => 3.4.0 
    gatsby-plugin-google-tagmanager: ^3.4.0 => 3.4.0 
    gatsby-plugin-image: ^1.4.0 => 1.4.0 
    gatsby-plugin-manifest: ^3.4.0 => 3.4.0 
    gatsby-plugin-netlify: ^3.4.0 => 3.4.0 
    gatsby-plugin-nprogress: ^3.4.0 => 3.4.0 
    gatsby-plugin-offline: ^4.4.0 => 4.4.0 
    gatsby-plugin-react-helmet: ^4.4.0 => 4.4.0 
    gatsby-plugin-robots-txt: ^1.5.6 => 1.5.6 
    gatsby-plugin-sass: ^4.4.0 => 4.4.0 
    gatsby-plugin-sharp: ^3.4.0 => 3.4.0 
    gatsby-plugin-sitemap: ^4.0.0 => 4.0.0 
    gatsby-plugin-smoothscroll: ^1.2.0 => 1.2.0 
    gatsby-remark-images: ^5.1.0 => 5.1.0 
    gatsby-remark-images-contentful: ^4.1.0 => 4.1.0 
    gatsby-remark-relative-images: ^2.0.2 => 2.0.2 
    gatsby-source-contentful: ^5.4.0 => 5.4.0 
    gatsby-source-filesystem: ^3.4.0 => 3.4.0 
    gatsby-transformer-remark: ^4.1.0 => 4.1.0 
    gatsby-transformer-sharp: ^3.4.0 => 3.4.0 
  npmGlobalPackages:
    gatsby-cli: 3.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugAn issue or pull request relating to a bug in Gatsby

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions