404 Redirect Issue - Gatsbyjs

Hi, I am having an issue with redirect. My project is using Gatsby, just a super simple static portfolio site. I just realized if I add any path after the url( eg. Home | Hosh'ki Tsunoda ), it should take the user to default 404 page but instead the same components get re-rendered and background image disappears. I can see 404 error in console.

I added _redirects file to the root of my project(same level as src folder) but no luck. I read it should be in public/ folder but that folder doesn’t exist in github.

It works in localhost.

Please assist. Thank you very much!

I believe the _redirects file needs to be in the directory that Netlify deploys (the /public directory). Alternatively, you can try using gatsby-plugin-netlify to create redirects.

2 Likes

gatsby-plugin-netlify worked beutifully:) Thank you!