1
3 Comments

Generating sitemap for a create-react-app

I feel like this is a dumb question but I am trying to generate a site map using https://www.xml-sitemaps.com/ which I've used in the past but first time with a create react app.

The project uses react-router-dom to create individual internal routes within the project. However, when I get the sitemap generator to run it doesn't find any links, just the 1 for the home page. I thought initially it might be because I forgot to add a rel=follow attribute to the link but then when looking at my blog (which uses Ghost) none of those links appear to have a rel=follow yet the sitemap generator sees all of the different links available within the blog site.

Is there something special that you have to do differently for a create-react-app to get a sitemap automatically generated in the same way?

posted to Icon for group Help
Help
on August 8, 2022
  1. 1

    most likely this tool doesn't have the ability to crawl the pages created by react. When you create internal routes they are not visible to external crawlers since they rely on server request and you are not making any request. You will need to generate static pages that you want to crawl. May be use nextjs or some other framework and configure it to generate static site with hydration.

    1. 1

      Thanks. I hadn't realised that. I have a terrible habit of forgetting sitemaps as an afterthought.

      I've done a bit more googling around and found there appears to be an npm package that can generate it, which I'll prob take a look at implementing - hopefully something simple.

      I have tried nextjs before (not for the sitemap just in general) didn't like it though, in fact I actually just converted a nextjs project back to a create-react-app.

Trending on Indie Hackers
I shipped 3 features this weekend based entirely on community feedback. Here's what I built and why. User Avatar 155 comments I'm a lawyer who launched an AI contract tool on Product Hunt today — here's what building it as a non-technical founder actually felt like User Avatar 139 comments Finally reached 100 users in just 12 days 🚀 User Avatar 127 comments “This contract looked normal - but could cost millions” User Avatar 53 comments 👉 The most expensive contract mistakes don’t feel risky User Avatar 39 comments I realized showing problems isn’t enough — so I built this User Avatar 32 comments