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?

  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
Reaching $100k MRR Organically in 12 months 29 comments 87.7% of entrepreneurs struggle with at least one mental health issue 13 comments How to Secure #1 on Product Hunt: DO’s and DON'Ts / Experience from PitchBob – AI Pitch Deck Generator & Founders Co-Pilot 11 comments Worst Hire - my lessons 11 comments Competing with a substitute? 📌 Here are 4 ad examples you can use [from TOP to BOTTOM of funnel] 10 comments Indie hackers selling to indie hackers? 7 comments