I’m trying to get a multilanguage theme done and I’ve encountered 2 issues:
How do you get a different landing page and partials for each language?
I’ve created mostly static /layouts/_default/index.html file (the only part that’s more “active” is the one that displays 4 latest posts). But obviously it should be different for each language.
The same goes for partials - in my case I’d like to have /partials/header.html translated for each of the languages.
I’ve read the following: Multilingual Mode | Hugo
but to be honest I’m not any closer to figuring it out. How do I use the i18list.html? Where do I put translated parts?
The landing page (/layouts/_default/index.html ) has links to images that are stored in the /static/images/ folder .
On the default language they display correctly, on the other languages they don’t display at all. Why? How do I fix it?
Here’s how I reference those:
Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.
If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.
it seems that simply creating index.html for a given language does the trick (so in my case that would be index.pl.html).
Would love to know if there’s a better way.
Use the language equivalent like you did or translate values in the i18n folder.
Create the language specific files inside the i18n folder based on the syntax you use with Hugo. For ToML using the example of English and French, you create a en.toml file and fr.toml file inside the i18n folder. Then to translate variables, you do it like below in both files
[title]
other = "your value here"
Then call that value in your templates/shortcodes with either {{ T "title" }} or {{ i18n "title" }}. If you have configured your languages properly, then the translated values should show when you switch languages. (Personally, I prefer this method over duplicating files in another language).