node package manager
We need your input. Help make JavaScript better: Take the 2017 JavaScript Ecosystem survey »

gatsby-plugin-sitemap

gatsby-plugin-sitemap

Create a sitemap for your Gatsby site.

Install

npm install --save gatsby-plugin-sitemap

How to Use

// In your gatsby-config.js
siteMetadata: {
  siteUrl: `https://www.example.com`,
},
plugins: [
  {
    resolve: `gatsby-plugin-sitemap`
  }
]

Above is the minimal configuration required to have it work. By default, the generated sitemap will include all of your site's pages except the dev 404 page (/dev-404-page/).

The default query as well as any of the other defaultOptions here can be overridden - for example:

// In your gatsby-config.js
siteMetadata: {
  siteUrl: `https://www.example.com`,
},
plugins: [
  {
    resolve: `gatsby-plugin-sitemap`,
    options: {
      output: `/some-other-sitemap.xml`,
      query: `
        {
          site {
            siteMetadata {
              siteUrl
            }
          }
 
          allSitePage {
            edges {
              node {
                path
              }
            }
          }
      }`
    }
  }
]

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