Multilingual site: publications folder

Hi, I am having an issue with content and layout structure. I have a 3 language website and all the pages are working but as soon as I started making a separate folder in the content and layouts to create a list page that will have multiple .md posts in the future, I ran into problems. I mean that the website hosts publications, which should be a list page containing different volumes (volume 1, volume 2, etc) and each volume needs a page of its own. The problem is currently all publications pages are displaying page not found, and I don’t think I understand the template lookup order because it’s a multilingual site so it’s not as straightforward here.

Please disregard the styling of the website, that is in progress. The website uses Tailwind btw. Any other comments about how the structure could be better are appreciated, it’s my first time using Hugo.

Could you please help set it up properly? Thank you. Here’s the repo.

hugo env:

hugo v0.121.2-6d5b44305eaa9d0a157946492a6f319da38de154+extended darwin/arm64 BuildDate=2024-01-05T12:21:15Z VendorInfo=brew
GOOS="darwin"
GOARCH="arm64"
GOVERSION="go1.21.5"
github.com/sass/libsass="3.6.5"
github.com/webmproject/libwebp="v1.3.2"
github.com/sass/dart-sass/protocol="2.3.0"
github.com/sass/dart-sass/compiler="1.69.7"
github.com/sass/dart-sass/implementation="1.69.7"

Rename publications.md to _index.md.

Thank you! I tried that before and it didn’t work - forgot to mention. I have now pushed this change you suggested to the repo, but as you can see nothing’s changed. Perhaps there is an issue with layout structure? or URLs… not sure what could be the culprit

To be precise, on localhost page Publications gives Page Not Found, and on Github Pages it’s an unstyled page for 2 languages, and an RSS feed for the default language. So weird!

I think you need to focus on getting it working locally first.

Thanks! Solved by adding single and list html templates to _default folder but I had to create single_language.html and list_languagage.html templates for each language there. So now I have several list and single html templates in “_default” I hope that’s not clunky. Perhaps there is a better way :eyes:

Apologies. I pulled your repo today and it works fine on my end.

I can see “Volume 1” fine and switch between languages. If I visit publications, I can see the image “Tokyo” and can switch between languages as well.

I haven’t encountered the “page not found” error you mentioned.

I’m using Hugo 0.125.1.

Hi @techmagus. Thank you. It is working now, but I am wondering if the solution was correct. If you check the _default layouts folder, you’ll see I created multiple list and single html pages and connected them as layouts for the corresponding content pages (via front matter). I am not sure if that’s how it’s supposed to work, or if there is a better way.

To visualize it better, here is the structure I am referring to.

- content 
   - en
     publications
       - _index.md
       - volume1.md

   - kz
     publications
       - _index.md
       - volume1.md

   
- layouts
   _default
     - list.html (connected to _index.md of publications of en)
     - single.html (connected to volume1.md of publications of en)
     - list_kz.html (connected to _index.md of publications of kz)
     - single_kz.html (connected to volume1.md of publications of kz)

Hmm… if each list.html is different, then your approach is a good one. However, if the list.html files are the same in every language, you can keep one list.html and single.html files.

Your /content/ structure will already work in a multilingual setup. If a visitor switches to kz, the /kz/publications/volume1.md file will be the one called. Basically, the only time you want to use a different layout via frontmatter is if the page should be loaded with a different layout (just backend, HTML and CSS).

If you’re creating a different layout file for each language because there are translations to be done, you can use {{ i18n }}, and then add the translations in /i18n/en.md and so on. So when the file like list.html and single.html are called by each language, it will pull the correct translation while keeping one list.html and single.html files.

Of course, again, if the layout itself is indeed different for each language, then creating a separate layout is good. For example, in /en/ the layout is probably 2 columns. In /kz/ the layout is 1 column + maybe a feature that makes sense to appear only in Kazakh.

I don’t have a sample repo, unfortunately (my live sites are using the Modules feature of Hugo, and are in separate repos), but try this test-repo I have:

I haven’t checked it against 0.125.x, hopefully it works.