404 in Multilingual site

Solution that worked for me (main language English + 4 other languages).

  • Single 404.html in layouts
  • Added config/development/server.toml for local redirects
  • In server.toml (French as an example):
[[redirects]]
	from = '/fr/**'
	to = '/fr/404.html'
	status = 404

[[redirects]]  # Default language should be last.
	from = '/**'
	to = '/404.html'
	status = 404
  • For redirects on Netlify, in netlify.toml (German as an example):
[[redirects]]
from = "/de/*"
to = "/de/404.html"
status = 404

Thanks to @idarek, @tfsomrat, and @jmooring for help.

2 Likes