3

I am using react-router-sitemap to generate sitemap.xml and successfully generated file in public folder after running npm run sitemap. But I need to update this file whenever I add new URL's to the site without creating build. I am using python/Django for backend

I followed this blog how to generate sitemap for react website

Is there any way by which I can run npm run sitemap after some conditions

vartika sharma
  • 93
  • 3
  • 13

1 Answers1

0

It really depends what the conditions are that you're looking to trigger the command, the blog post you linked actually gives a good way to do this, if you scroll down to the end of the blog post it mentions using a predeploy hook;

"scripts": {
  "predeploy": "npm run sitemap"
}

using this predeploy hook will run npm run sitemap before it runs npm run deploy whenever you deploy your application, assuming you deploy your application by running npm run deploy and assuming there's also a deploy script in your package.json

Grant
  • 446
  • 6
  • 24
  • But for this we need to deploy the project everytime a new URL adds in site. I want to run sitemap-generator every time a new URL add to the site. – vartika sharma Jan 21 '20 at 09:29