Multilingual site on GitHub Project Pages issue with non-default language URLs

Hi there !

Firstly, as this is my first post here, a BIG thank you to the whole Hugo community and its developers, it’s a really great FOSS project !

I’m currently developing a multilingual site and its custom theme. In addition to the local development environment, I use GitHub Pages (as a Project/Repository site type) as a testing bed and for other contributors to have a look at the WIP.

The default language is English and a few languages were set up for testing. In the local environment, all language pages are correctly linked. On GitHub Pages, all non-default language ones (other than English) are linked with an unnecessary Language Code between my default GitHub user domain and the project name, leading to non-existing URLs. Example:

English page on local environment URL : localhost:1313/page/
French page on local environment URL : localhost:1313/fr/page/

English page on GitHub Project Pages URL : user.github.io/your-github-project/page/
French page on GitHub Project Pages URL : user.github.io/fr/your-github-project/fr/page/
instead of the expected : user.github.io/your-github-project/fr/page/

Thanks for any hint :grin:

Local env
hugo v0.129.0-e85be29867d71e09ce48d293ad9d1f715bc09bb9 linux/amd64 BuildDate=2024-07-17T13:29:16Z VendorInfo=gohugoio
GOOS="linux"
GOARCH="amd64"
GOVERSION="go1.22.2"

Seems to be working now. What was the issue?

Hi @frjo
Thanks for having a look !
I’ve corrected the first post to make it clearer.

However, I’ve solved most of my problems :

I was over-using the relLangURL in places where it is not needed (e.g. pages where the context is already taking care of the language).
Strangely enough, in local dev, two same following language prefix are merged into one (e.g. the /fr/ prefix of relLangURL for a /fr/page returns also /fr/page), whereas on GitHub Project Pages the language prefix is added at the domain root (e.g. the /fr/ prefix of relLangURL for a /fr/page returns /fr/your-github-project/fr/page).

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