How to create a sitemap for a Gatsby site

January 24, 2021

Install the Gatsby plugin:

npm install gatsby-plugin-sitemap

Then, add the root URL of your site (before the part that starts with /) to your gatsby-config.js, and activate the plugin:

// gatsby-config.js

module.exports = {
  siteMetadata: {
    siteUrl: ""
  plugins: [

Done! Your sitemap will be created at /sitemap.xml in production builds of your Gatsby website, and will also be properly linked in the <head> of each page.

A quick favor: was anything I wrote incorrect or misspelled, or do you still have questions? Please use this form to let me know or ask for help!