Missing images in untranslated posts in multilingual configuration

Just wanted to check whether my understanding or configuration is right, before submitting a bug.
It seems related to #12167 but there seems to be a missing case.

The primary language is English, and a few of my posts, exist only in Greek. As in the following example, post2 exists in both languages, but post1 only exists in Greek. Each of them has a markdown image tag such as ![](./cover2.jpg).

The cover1.jpg image is neither displayed nor exists in the /public/ folder, but cover2.jpg image is displayed without any issues in the respective post.

:point_right: Shouldn’t the images just work in both cases?

Example content tree:

content/
├── post1/
│   ├── index.el.md
│   └── cover1.jpg
└── post2/
    ├── index.el.md
    ├── index.en.md
    └── cover2.jpg

I also tried {{ (.Resources.ByType "image") }} in a template, and indeed it’s empty for the first bundle. The images are only recognized as resources when a index.en.md is created in the post1/ directory. Changing the defaultContentLanguage to the secondary language also resolves this.

I tried several past versions of Hugo and as expected this is only introduced after v0.123.

My configuration (see full config) as follows:

defaultContentLanguage: en
languages:
  en:
    weight: 1
    languageName: English
    languageCode: en
  el:
    weight: 2
    languageName: Ελληνικά
    languageCode: el

My arguments, if that helps: hugo.exe server -O -D --port=1313 --noHTTPCache --disableFastRender

PS: Related previous discussion: Issue with images in a multilingual multihost configuration

That discussion is about something else.

Your results are expected. See:
https://github.com/gohugoio/hugo/issues/12107

You can rename content/post1/cover1.jpg to content/post1/cover1.el.jpg.

If a translation exists for the default content language, its page resources are available to other translations.

If a translation does not exist for the default content language, you must create language-specific page resources.

Thank you, the Github issue discussion is helpful.

I understand the rationale is to be cautious of unused resources, but as others have noted this behavior is counter-intuitive against the i18n defaults. Plus it may be valid to denote the language in the filename for other resources, but when it comes to images —in my opinion— they shouldn’t need a language indicator, unless they contain text or specific features where their content makes sense to be translated or localized.

The easiest “future-proof” work-around seems to be creating an index.md for the default language with the following contents:

---
headless: true
---

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