# Custom 404 per language

**URL:** <https://discourse.gohugo.io/t/custom-404-per-language/20239>\
**Category:** support\
**Tags:** i18n\
**Created:** [August 15, 2019, 10:07pm UTC](https://discourse.gohugo.io/t/custom-404-per-language/20239 "2019-08-15T22:07:53Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![brunoamaral](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/brunoamaral/32/21144_2.png) [@brunoamaral](https://discourse.gohugo.io/u/brunoamaral)\
**Post date:** [August 15, 2019, 10:07pm UTC](https://discourse.gohugo.io/t/custom-404-per-language/20239/1 "2019-08-15T22:07:53Z")

</div>

I was using 404.html and 404.pt.html in /layouts/ to serve different pages when the server returned a 404 in the default language or Portuguese.

Looking at it today, both of the built files are the initial 404.html. Did something change in the way Hugo builds this page?

---

<div class="post-metadata">

**Author:** ![ju52](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/ju52/32/6749_2.png) [@ju52](https://discourse.gohugo.io/u/ju52)\
**Post date:** [August 16, 2019, 10:11am UTC](https://discourse.gohugo.io/t/custom-404-per-language/20239/2 "2019-08-16T10:11:27Z")

</div>

You have to find a way to config different 404 pages in your web server ☹  
At best implement both languages in one page.

---

<div class="post-metadata">

**Author:** ![brunoamaral](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/brunoamaral/32/21144_2.png) [@brunoamaral](https://discourse.gohugo.io/u/brunoamaral)\
**Post date:** [August 16, 2019, 11:18am UTC](https://discourse.gohugo.io/t/custom-404-per-language/20239/3 "2019-08-16T11:18:59Z")

</div>

The server is working like intended, the problem here is that the page built in /404.html and /pt/404.html are the same.

---

<div class="post-metadata">

**Author:** ![ju52](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/ju52/32/6749_2.png) [@ju52](https://discourse.gohugo.io/u/ju52)\
**Post date:** [August 16, 2019, 12:28pm UTC](https://discourse.gohugo.io/t/custom-404-per-language/20239/4 "2019-08-16T12:28:00Z")

</div>

with this hint

> **[Multilingual Mode](https://gohugo.io/content-management/multilingual/#translation-by-filename)**
>
> Hugo supports the creation of websites with multiple languages side by side.

try with 404.pt.html

---

<div class="post-metadata">

**Author:** ![brunoamaral](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/brunoamaral/32/21144_2.png) [@brunoamaral](https://discourse.gohugo.io/u/brunoamaral)\
**Post date:** [August 16, 2019, 1:07pm UTC](https://discourse.gohugo.io/t/custom-404-per-language/20239/5 "2019-08-16T13:07:47Z")

</div>

Yes, that’s my current setup and it was working.

> [@brunoamaral](#):
>
> I was using 404.html and 404.pt.html in /layouts/

---

<div class="post-metadata">

**Author:** ![davidsneighbour](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/davidsneighbour/32/24507_2.png) [@davidsneighbour](https://discourse.gohugo.io/u/davidsneighbour)\
**Post date:** [August 16, 2019, 1:20pm UTC](https://discourse.gohugo.io/t/custom-404-per-language/20239/6 "2019-08-16T13:20:41Z")

</div>

Could it be connected to your earlier issue (that I can’t find now)? I remember we had a little back and forth about something related to PT.

I am pretty sure that /layouts/404.pt.html is supposed to be the 404 page for Portuguese and we have a bug here.

Does Hugo debug anything specific with `hugo --i18n-warnings`?

---

<div class="post-metadata">

**Author:** ![brunoamaral](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/brunoamaral/32/21144_2.png) [@brunoamaral](https://discourse.gohugo.io/u/brunoamaral)\
**Post date:** [August 16, 2019, 1:59pm UTC](https://discourse.gohugo.io/t/custom-404-per-language/20239/7 "2019-08-16T13:59:54Z")

</div>

That one was about resources, but maybe it is connected with this one.

Just tried i18n-warnings and it built like expected, with no error.

---

<div class="post-metadata">

**Author:** ![ndalliard](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/ndalliard/32/9935_2.png) [@ndalliard](https://discourse.gohugo.io/u/ndalliard)\
**Post date:** [February 24, 2020, 2:11pm UTC](https://discourse.gohugo.io/t/custom-404-per-language/20239/8 "2020-02-24T14:11:31Z")

</div>

Same problem here. Following [Custom 404 Page](https://gohugo.io/templates/404/) in the docs, I would assume adding a `layouts/404.de.html` should work, but it doesn’t.

---

<div class="post-metadata">

**Author:** ![guinuxbr](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/guinuxbr/32/11009_2.png) [@guinuxbr](https://discourse.gohugo.io/u/guinuxbr)\
**Post date:** [April 9, 2020, 1:15am UTC](https://discourse.gohugo.io/t/custom-404-per-language/20239/9 "2020-04-09T01:15:45Z")

</div>

I have the same problem with Github Pages.

My blog have two languages and the 404.html is in the root of both folders, but it is not rendering.

Is there any known solution?

---

<div class="post-metadata">

**Author:** ![mburger](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/mburger/32/14856_2.png) [@mburger](https://discourse.gohugo.io/u/mburger)\
**Post date:** [July 23, 2021, 12:50pm UTC](https://discourse.gohugo.io/t/custom-404-per-language/20239/10 "2021-07-23T12:50:57Z")

</div>

It seems that Hugo does not support [translation by filename](https://gohugo.io/content-management/multilingual/#translation-by-filename) for 404 pages.

I am using the i18n function to [translate strings](https://gohugo.io/content-management/multilingual/#translation-of-strings) within the singe 404.html file.

---

<div class="post-metadata">

**Author:** ![martignoni](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/martignoni/32/5756_2.png) [@martignoni](https://discourse.gohugo.io/u/martignoni)\
**Post date:** [July 23, 2021, 2:44pm UTC](https://discourse.gohugo.io/t/custom-404-per-language/20239/11 "2021-07-23T14:44:50Z")

</div>

Also using i18n function. See this working example:

> <https://github.com/moodlebox/moodlebox.net/blob/master/layouts/404.html>
