Hugo + React Router

Hi everyone.

This is the first time posting here so do let me know if this is not the place to be asking these kind of questions.

I’m currently building an SPA and I want to use Hugo as a page generator for it. This allows me to have a blog alongside the actual application.

The way I did this is by creating content/admin/ and I have an if statement that displays a div for react to be inserted in under the list.html template. So far this all works but if there’s any best practive, do let me know :slight_smile:

The issue I’m having is that I use React Router which will lead the user to links such as /admin/feature. When developing on the app, this link doesn’t actually exist within Hugo and therefore, a 404 gets thrown. Is there any way around this? Ideally, it would be good to have a “default” fallback template for “posts” that are in the admin category.

I know this sounds like a hack so any suggestions are welcome :slight_smile:

Thanks in advance!

What is a SPA?

Single page application :slight_smile:

I hope you get the help you need. I’d post this in a React forum, too; your question may have to do more with developing alongside a static-built site, in a generic sense. :slight_smile:


I thought that the hugo server command was the one who’d route me to a 404 if a specific static file is missing. But you do have a point, this could happen in any static page builder so I will try there as well.

Does anyone else have any suggestions?