How can list.html show all language variants?

How can list.html show all language variants?

Now list.html shows all md pages, except when they have a language setting, like i.e. page.gr.md. I want to display all page.

Currently in list.html I use {{ range .Pages }}

in config.toml

DefaultContentLanguage = "en"
[languages]
[languages.en]
languageName = "English"
weight = 1
[languages.gr]
languageName = "Greek"
weight = 2

Reason: different languages should show in the same folder. I only want to switch language to get
hugo-notice translated.

{{ range .Pages }}
  {{ range .AllTranslations }}
    <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
  {{ end }}
{{ end }}
1 Like

It’s not working. Pages not showing.

I have a repo: GitHub - 4044ever/pizza2

I may just change that in the hugo-notice shortcode, I don’t think I will heavily use it anyway.

Thank you for sharing your repo; now I understand the problem. You don’t have translations; you have a mix of content in different languages. For example:

content/
β”œβ”€β”€ posts/
β”‚   β”œβ”€β”€ bar.de.md
β”‚   └── foo.md
└── _index.md

To have the posts list page display both foo and bar:

{{ range where (where site.AllPages "Type" "posts") "Kind" "page" }}
  <h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
{{ end }}

See https://gohugo.io/variables/site/#site-variables-list

Additionally, your use of the url front matter variable on the posts index page is causing a page collision, which can create unexpected results depending on the sequence in which the pages are rendered.

Run hugo --printPathWarnings.

I would re-work your home template to range through the posts.

Thank you for looking into this! It partly works. I get the translated file displayed, but without CSS for the hugo-notice boxes (they are not on the live site). On my look into list.

For the hugo --printPathWarnings I need to look into that and digest that a bit. I get:
WARN 2022/05/10 22:56:55 Duplicate target paths: \index.html (2), \index.xml (2)

I am unclear what that means. It’s kinda late, will go on tomorrow.

It means that the home page is rendered twice, and the last one to be rendered clobbers the other.

I didn’t manage to fix that. I did some note boxes without i18n functionality and with TailwindCSS. Would allow me also to use different language notes in the same *.md if I want to.