Multilanguage support and non-localized images

Hi,

I currently have the following layout in my blog:

content/App1/
├── _index.de.md
├── _index.en.md
└── Verwaltung
    ├── Benutzerverwaltung
    │   ├── Benutzerverwaltung.de.md
    │   ├── Benutzerverwaltung.en.md
    │   └── resources
    │       ├── mail-address.png
    ├── _index.de.md
    └── _index.en.md

My defaultContentLanguage is set to de. I use the localized _index.md files to build a menu for each language. When compiling this site, the image mail-address.png is only copied to the de site but not to en. If I open the de-Site, the image is correctly shown but not on the en.

Things I tested:

  • Localize the image with mail-address.en.png and mail-address.de.png: This works but leads to duplicated files in my repo for each language even though the content is the same. From hugos perspective these might be even two different files.

Is there any way to reference the image from both files Benutzerverwaltung.en.md and Benutzerverwaltung.de.md as mail-address.png and have it shown on both languages?

I’m not sure I completely understand your objective, but converting Benutzerverwaltung into a page bundle works great:

content/
├── App1/
│   ├── Verwaltung/
│   │   ├── Benutzerverwaltung/
│   │   │   ├── resources/
│   │   │   │   └── mail-address.png
│   │   │   ├── index.de.md  <-- file name does not begin with underscore
│   │   │   └── index.en.md  <-- file name does not begin with underscore
│   │   ├── _index.de.md
│   │   └── _index.en.md
│   ├── _index.de.md
│   └── _index.en.md
├── _index.de.md
└── _index.en.md

Example:

git clone --single-branch -b hugo-forum-topic-50950 https://github.com/jmooring/hugo-testing hugo-forum-topic-50950
cd hugo-forum-topic-50950
hugo server

This assumes that you have not created a link render hook, and that the themes/modules you are using are not supplying a link render hook.

Resource deduplication for multilingual single-host sites is described here:
https://gohugo.io/content-management/page-resources/#multilingual

Thank you for your reply. This seems to work when

  • I disable the custom render-image.html provided by hugo-book theme
  • I explicitly name the files index.<LanguageCode>.md

The need for that specific filename is a dependency for being recognized as a page bundle?

Yes, you must name the file index.md.

1 Like

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