Netlify Sitemap Plugin: How to Exclude Certain Pages

In one of the previous post, we discussed how to automatically generate a sitemap for a website (Specifically Static Site) using Netlify sitemap plugin.

But in this post, we would be looking at how to exclude some certain pages that we donโ€™t want to show on the sitemap page, since Google will crawl and index whatever it finds in the sitemap.

Go to your netlify.toml config file and add the following code to it.

[[plugins]]
  package = "@netlify/plugin-sitemap" # The netlify sitemap plugin
  
  [plugins.inputs]
    exclude = [
      '**/admin',    # Excluding the admin folder for netlifyCMS
      '**/contact.html',  # Excluding contact page
      '**/404.html',  # Excluding 404 page
    ]

Note:

Every pages like /contact, /about or /404 need .html to be added but in the case of the admin folder, you donโ€™t put .html since it is a folder used for Netlify CMS