Netlify sitemap plugin and excludes

Hello I am a #netlify-newbie and thus far I :heart: netlify. Today I started playing around with the new Netlify Build-Plugins (beta).

I am working on moving a site from WordPress to Eleventy so I decided to use the https://github.com/netlify-labs/netlify-plugin-sitemap. It works great!

However, I’m also using Netlify CMS and I am wondering is it possible to exclude the /admin login from the sitemap?

I googled around and checked the community before posting but I didn’t have much luck. Thanks in advance for your help.

Thank you.

Hi @adamdjbrett, welcome to the Netlify community. I took a look at the source code of that plugin and it seems that it just finds all the HTML pages without any extra logic: netlify-plugin-sitemap/index.js at main · netlify-labs/netlify-plugin-sitemap · GitHub

I suppose the best way forward is to open up a feature request in the repository, it shouldn’t be too hard to implement a regex that excludes certain paths.

Hey @adamdjbrett

Welcome to Netlify & the JAMStack!

Ask and you shall receive! I’ve added support for exclusions in the sitemap plugin. Add exclude feature by DavidWells · Pull Request #3 · netlify-labs/netlify-plugin-sitemap · GitHub

Install the latest version and you will be able to set exclude option. See the exclude docs here

npm install @netlify/plugin-sitemap@0.2.0 --save-dev

Have a good day :smiley:

3 Likes

Damn that was quick! Nice :ok_hand:

Thank you so much for adding exclusions to the sitemap that is wonderful. Is there a projects board for the plugin? Because it would be great if future versions could respect Netlify Pretty URLs and/or YAML frontmatter permalinks.

Seriously thank you so much.

Hey Adam! I’d suggest you file a feature request on the repo directly (or submit a PR yourself if you had ideas on implementation)- I think that most of the netlify-labs projects are not quite at the level of having a project board yet :wink:

The sitemap plugin has been updated to automatically use Pretty URLs

Pretty urls means:

site.com/index.html being turned into site.com/
site.com/sub-folder/index.html being turned into site.com/sub-folder
etc.

Users can opt out with the prettyURLs config option GitHub - netlify-labs/netlify-plugin-sitemap: Automatically Generate sitemaps on build

1 Like