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
To configure the plugin, edit the
[[plugins]] package = "@netlify/plugin-sitemap" [plugins.inputs] buildDir = "dist/" exclude = [ # To exclude the path from the sitemap '**/admin/*' ]
This will generate sitemap at
/sitemap.xml on every production build.To check more about configuration, you can check their official documentation.
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
Now in the same
netlify.toml file, add the following.
[build] publish = "public" [[plugins]] package = "netlify-plugin-submit-sitemap" [plugins.inputs] # 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 = [ "google", "bing", "yandex" ]
This will ping the search engines everytime after a new build using
You can also refer to their official documentation.