Giving a single-page app a real 404 page
What happened
The site is a single-page app with no catch-all route. Any unknown path, such as a mistyped URL or an old link, just rendered the home page.
That causes two problems. Search engines can see many soft-404 duplicates of the home page, which wastes crawl budget and can dilute the canonical URL. Visitors also land on a page that doesn't tell them they took a wrong turn.
The fix / What I built
I added a small NotFound route. It's a lazy-loaded component, and a catch-all route in the routed app renders it for any path that nothing else matches.
The page does three things:
- It shows "Page not found".
- It links back to the main pages of the site.
- It sets a noindex meta tag when it mounts.
Why it works
The router now has an explicit answer for unknown paths instead of falling through to the home page. People see a clear message with a way back. The noindex tag tells crawlers not to index these URLs, so they stop competing with the real home page.