Skip Navigation

02 Jan 2022

Automating Sitemap Workflow

Sahil Kokamkar
Unsplash Credit:@e_sykes

Generating sitemap

To generate sitemap first add the @netlify/plugin-sitemap as Dev dependency in package.json using npm, yarn, pnpm or any other package node package manager of your choice.

npm install @netlify/plugin-sitemap --save-dev-dev
yarn add @netlify/plugin-sitemap --dev
pnpm add -D @netlify/plugin-sitemap

Configuring the plugin.

To configure the plugin, edit the netlify.toml file.

package = "@netlify/plugin-sitemap"

  buildDir = "dist/"
  exclude = [
    # To exclude the path from the sitemap

This will generate sitemap at /sitemap.xml on every production build.To check more about configuration, you can check their official documentation.

Submitting sitemap

Now after we have sitemap we can automate its submission, first we have to install netlify-plugin-submit-sitemap as Dev Dependency.

npm install @netlify-plugin-submit-sitemap --save-dev-dev
yarn add @netlify-plugin-submit-sitemap --dev
pnpm add -D @netlify-plugin-submit-sitemap

Configuring the plugin

Now in the same netlify.toml file, add the following.

  publish = "public"

  package = "netlify-plugin-submit-sitemap"


    # The base url of your site
    baseUrl = "https://yoursite.tld"

    # Path to the sitemap
    sitemapPath = "YourPath/sitemap.xml"

    # Submitting sitemap to search engines. You can also remove those you don't what to submit
    providers = [

This will ping the search engines everytime after a new build using ping?sitemap=.

You can also refer to their official documentation.