Hello!
I am working on a company documentation project done in Hugo, using Docsy. I am developing a multilingual support for the documentation page. The problem is that, it follows the Docsy standard and is totally different of my personal site that points the same images to all languages with success. The company’s document project doesn’t work with {{range .Resources.Match "images/*"}}
.
I want to point static/images
to all languages without needing to duplicate or copy to each language folder.
Please analyse the tree:
- content
- en
- ajuda
- _index.html
- pt_br
- ajuda
- _index.html
- i18n
- en.toml
- pt-br.toml
- layouts
- shortcodes
- blocks
- feat.html
- item.html
- static
- images
- ilust-conheca.jpg
- ilust-doc.jpg
- ilust-pergunte.jpg
And analyse only the intem.html
. Observe {{ $img := .Get "img" | default "/images/ilust-doc.jpg" }}
. It renders <img src="images/ilust-pergunte.png" alt="Imagem description">
in both languages. In Portuguese, it renders correctly the images, but in English, it doesn’t render.
{{ $icon := .Get "icon" | default "fa-lightbulb" }}
{{ $img := .Get "img" | default "/images/ilust-doc.jpg" }}
{{ $alt := .Get "alt" | i18n "image_description" }}
{{ $url_text := .Get "url_text" }}
{{ $grid_lg := .Get "grid_lg" | default "4" }}
{{ $grid_md := .Get "grid_md" | default "3" }}
<div class="col-lg-{{ $grid_lg }} col-md-{{ $grid_md }} mb-5 mb-lg-0 {{ .Get "text-direction" }} {{ .Get "custom" }}">
<div class="td-box-item">
<div class="mb-2 h1 td-box-item-ilust">
{{ with .Get "img" }}
<img src="{{ $img }}" alt="{{ $alt }}" />
{{ end }}
{{ with .Get "icon" }}
<i class="{{ if not (or (hasPrefix $icon "fas ") (hasPrefix $icon "fab ")) }}fas {{ end }}{{ $icon }}"></i>
{{ end }}
</div>
<div class="td-box-item-content">
<h4 class="h3">{{ .Get "title" | markdownify }}</h4>
<p class="mb-0">{{ .Inner }}</p>
{{ with .Get "url" }}
<p>
<a href="{{ . }}">{{ with $url_text }}{{ $url_text }}{{ else }}{{ T "ui_read_more" }}{{ end }} …</a>
</p>
{{ end }}
</div>
</div>
</div>