How do I upload a sitemap.xml file to Heroku?

287 views Asked by At

I am using Node.js. My app is already in production. I created a sitemap.xml in my local directory but it currently identified as Untracked.

There are other answers that pertain to Ruby but I am unfamiliar with the language.

How do I push my file to Heroku?

1

There are 1 answers

1
Michael Asiedu On

if you're using ExpressJs, you need to create a route for sitemap and robots.txt

app.get("/sitemap.xml", (req, res) => res.sendFile(__dirname + "/sitemap.xml"));

You can use the same procedure for your robots.txt files!

You can now push to Heroku and it will be tracked successfully!