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
30 days ago I posted here with $0 revenue. Here's what actually happened next. User Avatar 148 comments I used $30,983 of AI tokens last month in Claude code on $200/mo plan User Avatar 90 comments my reddit post got 600K+ views. here's exactly what i did User Avatar 58 comments How to spot high-intent customers in 5 minutes, for free. User Avatar 44 comments Fixing broken scrapers instead of working on my actual product. So I made it my problem. User Avatar 37 comments I Built a Habit Tracker SaaS Alone in 6 Weeks (No CS Degree, No Team). Here's Exactly How User Avatar 37 comments