Custom i18n urls for 404 pages in Github pages with Jekyll

Well, the question is simple, I’m using jekyll-language-plugin on my Jekyll website.

I have created the following yaml config on my 404.html page (this is the front matter config):

---
layout: error
title: 404
languages:
- en
- es
subset: err
---

The problem is that if for example I visit: localhost:4000/aaa everything works fine. But if I visit: localhost:4000/es/aaa something wrong happens.

Although, in my _site/es/ folder there is a 404.html file (that is translated into Spanish), it can’t be loaded.

My thoughts are that Jekyll is processing “/es/aaa” as the 404 url, instead of “aaa” (that is what I need).

I have been searching for a while, and the only thing related to this I found was a tutorial from Jekyll docs that shows how to create a custom 404 page.

There is a suggestion to use Apache (through .htaccess file) or Nginx configuration files to achieve this. The problem is that I’m on Github pages, so this is not allowed for me.

Is there any workaround for this (plugin, config, etc etc)?

have you tried it with a / on the end?

the urls without a trailing slash get a little complicated, I don’t remember if GH supports them, I want to say they don’t, and that is where the .htaccess file comes in - the server is what controls it.

But if you get the first one to work locally without the / then maybe the /es/ files don’t have the same permalink structure?

personally I find the trailing slash easier to work with.

One workaround for Github single /404.html page would be to use Javascript’s navigator.language property on the 404 page to detect the user’s preferred language, and display an appropriate message.