1

Sitemap Doesn't work I can't get the site map URL and I can't use the /sitemap.xml URL How do I fix it??

  siteMetadata: {
    siteUrl: siteAddress.href, // which is "https://www.example.com/"
  },
 {
  resolve: `gatsby-plugin-sitemap`,
  options: {
    head: true,
    output: `/sitemap.xml`,
  }
John Conde
  • 217,595
  • 99
  • 455
  • 496
maki
  • 21
  • 2

1 Answers1

2

Have you tried building your project? From the docs:

NOTE: This plugin only generates output when run in production mode! To test your sitemap, run: gatsby build && gatsby serve

In addition, your plugin's options are not valid: head should be createLinkInHead. A full sample with queries should look like:

 {
    resolve: `gatsby-plugin-sitemap`,
    options: {
      output: `/some-other-sitemap.xml`,
      createLinkInHead: true,
      exclude: [`/category/*`, `/path/to/page`],
      query: `
        {
          wp {
            generalSettings {
              siteUrl
            }
          }

          allSitePage {
            nodes {
              path
            }
          }
      }`,
      resolveSiteUrl: ({site, allSitePage}) => {
        return site.wp.generalSettings.siteUrl
      },
      serialize: ({ site, allSitePage }) =>
        allSitePage.nodes.map(node => {
          return {
            url: `${site.wp.generalSettings.siteUrl}${node.path}`,
            changefreq: `daily`,
            priority: 0.7,
          }
        })
    }
  }

Alternatively, you can use gatsby-plugin-advanced-sitemap which has more customizable options.

Ferran Buireu
  • 28,630
  • 6
  • 39
  • 67