Customize 404 Page with Github Page

Hi,
I have a blog powered by Hugo. I deploy the bog on Github Page, I have followed the Hugo documentation page on 404 Custom page. But As I can see, it is not working on my blog when it is deployed.

I have put a 404.html file in my layouts directory (as you can see in my repo GitHub - throdoProudfoot/outme-blog: A simple blog to tchat about Middle-Earth Roleplaying and FoundryVTT (Once Upon a Time in Middle-Earth)) but when the blog is built and deployed (GitHub - throdoProudfoot/throdoProudfoot.github.io at gh-pages), you only have 404.html file in the language directories (en and fr) but not at the root. And Github Pages expect the file at the root of the site.

Do you know how to fix that please to have my 404 file to be displayed ?

There does not appear to be a clean way to accomplish this.

Workaround:
https://discourse.gohugo.io/t/global-404-page-for-a-multilingual-site/20979/2

Related:
https://github.com/gohugoio/hugo/issues/5161

1 Like

thanks for your quick answer. i am relieved it is not my fault but more an issue with Hugo.

I have to find out how to make github actions to copy the /en/404.html to the root directory :slight_smile:

Generate the project locally and then simply copy the 404.html from the language directory under /static/.

The staticDir lives outside Hugo’s Multilingual Mode, therefore a 404.html under the root of /static/ will be served under the root of the domain without having to use any shell command during deployment.

1 Like

yes, you’re right it is straight forward.

I use the hugo command to create the public directory then I copy the 404.html in the /static directory.

Great. thanks a lot.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.