I don’t remember exactly when I first met Hugo to say for sure it didn’t have multilingual support or if what was available was as it is today. But, be it because of limitations at that time or lack of knowledge of my part for “more complex features”, back then I ended up translating a fan-site by “brute-force”
All translatable files always had the language suffix between the filename and the extensions (i.e. about.en.md
) but everything else, like listing all available translations, the relationship between Pages and even the Language Switcher, had been created by hand.
Now, after migrating a lot of data from FrontMatter Parameters to Data Files, already in the much more efficient subdirectories format (i.e. /data/en/file.json
), I decided to revisit the i18n/l10n as well and with a few changes in my config.yaml
(see below), almost everything was up and running smoothly (I’m still figuring out how to deal with URLs…).
However, after compiling, I noticed that everything under /static
was getting duplicated for each language available and that’s most undesirable for me because there are several pictures under /static/assets/images
used regardless the language chosen, summing something around 80 MB — and that’s already super optimized.
This is the meaningful part of the new config.yaml
:
languages:
en:
languageName: English
baseURL: https://www.site.com/
contentDir: content/en
weight: 1
pt:
languageName: Português
baseURL: https://pt.site.com/
contentDir: content/pt
weight: 2
es:
languageName: Español
baseURL: https://es.site.com/
contentDir: content/es
weight: 3
And this the static folder directory:
|-\ static
|-\ assets
|-\ fonts
|-\ images
|-\ js
|-\ css
|-\ en
|-\ pt
|-\ es
js and css don’t actually exist. They’re added in there when resources are compiled and minified
After compiling, I’m receiving as output this structure:
|-\ public
|-\ en
|-\ assets
|-\ pt
|-\ assets
|-\ es
|-\ assets
While I would need something like:
|-\ public
|-\ en
|-\ pt
|-\ es
|-\ assets
I would prefer all subfolders within
/static
to remain under/assets
, this way I can Cache-Control them all with a single rule in CloudFlare and etc.
I’ve found this issue relating a case pretty much like what I’m experiencing. But as you can see there’s no global staticDir
nor a per-language staticDir2
defined.