DEV Community 👩‍💻👨‍💻

Cover image for Excluding certain paths
Top
Top

Posted on

Excluding certain paths

Unless you're extremely lucky, it's likely that this sitemap isn't quite right.

One of the biggest reasons to add a sitemap is to tell Google which pages not to worry about. For example, my blog had the following sites specified in the original version of my sitemap:

<url>
  <changefreq>daily</changefreq>
  <priority>0.5</priority>
</url>
<url>
  <changefreq>daily</changefreq>
  <priority>0.5</priority>
</url>
Enter fullscreen mode Exit fullscreen mode

admin is an authenticated route I use for viewing stats about the website, and confirmed is shown when users join my newsletter. Neither of these pages makes sense to include in search results.

Happily, we can customize the plugin to pass an array of paths to exclude:

// gatsby-config.js
module.exports = {
  siteMetadata: {
    // ✂️
  },
  plugins: [
    {
      resolve: 'gatsby-plugin-sitemap',
      options: {
        exclude: ['/admin', '/confirmed'],
      },
    }
    // ✂️
  ],
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Thank you.

 
Thanks for visiting DEV, we’ve worked really hard to cultivate this great community and would love to have you join us. If you’d like to create an account, you can sign up here.