Multilingual mode not rendering the shared page bundle images

/content/proposal/dwb/index.en.md

title: proposal
description: proposal
og_type: 'article'
client: dwb
chapters:
1: overview
2: what we do
3: contact
slug: 'dwb'

/content/proposal/dwb/index.zh.md

title: proposal
description: proposal
og_type: 'article'
client: dwb
chapters:
    1: overview
    2: what we do
    3: contact
slug: 'dwb'

/hugo.toml

baseURL = 'https://doc.curagenc.com'
[params]
description = "strategic communication and branding for cultural and creative influence"
images = []
title = 'Curagenc | xx咨询'
defaultContentLanguage = 'en'
defaultContentLanguageInSubdir = true
[services]
[markup]
[markup.tableOfContents]
endLevel = 2
ordered = false
startLevel = 1
[markup.goldmark.renderer]
unsafe = true
[languages]
[languages.en]
languageCode = 'en'
languageName = 'ENG'
weight = 1
[languages.zh]
languageCode = 'zh'
languageName = '中文'
title = 'xx咨询 | xxxxx'
weight = 2

WhenI use ![some image](aio-01.jpg) in both index.en.md and index.zh.md, only the english version shows the image. My image is placed within the same directory as the markdowns, in /content/proposal/dwb.

How do I fix this?

You might need to add this code to your configuration file—

[markup]
  [markup.goldmark]
    duplicateResourceFiles = true

See Page resources | Hugo

1 Like

Thanks!

For the record, this is almost always wrong:

[markup.goldmark]
duplicateResourceFiles = true

By doing this you are masking the problem, not solving it, and at the same time you are disabling a powerful feature that reduces build times, storage requirements, bandwidth consumption, and deployment times, ultimately reducing cost.

it suddenly works again with my original code, even without duplicateResourceFiles. I have no idea how it happened.

Clear your public directory and test again to make sure it’s working.

If it is not working, are you using any render hooks?

I just cleared it, and upon refresh, NOT working again. I don’t think I am using any render hooks as I don’t really know what they do.

I am not using any theme btw.

To understand and properly solve the problem I would need access to the entire project. Please post a link to your project’s Git repository.

See Requesting Help.

Let us see your code

Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.

If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.

Just commit it the first time.

I can’t build your site. Here’s what I did:

git clone --recurse-submodules https://github.com/jesvtb/curagenc_doc
cd curagenc_doc/02_program/
hugo

Here’s what I got:

WARN  found no layout file for "html" for kind "taxonomy": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN  found no layout file for "html" for kind "section": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
ERROR TOCSS: failed to transform "/index.scss" (text/x-scss): "/home/jmooring/temp/curagenc_doc/02_program/assets/index.scss:1:1": File to import not found or unreadable: /Users/jessicaluo/FileServer/2_BUSINESS/22_Curagenc/03_Marketing/32_Collateral/Website/03_Program/assets/css/reset.scss.

The first two warnings I always have and still manage to build the site.

Just fixed the last stylesheet loading error by using a local file.

Warnings are emitted for a very good reason. While the site may build, I strongly encourage you to fix underlying problem.

okay, fixing them as of now

This works as expected:

![](aio-01.jpg)

The problem is with this:

{{< img aio-01.jpg >}}

Your shortcode needs to look for a page resource.

layouts/shortcodes/img.html
{{- $u := urls.Parse (.Get 0) -}}
{{- $src := $u.String -}}
{{- if not $u.IsAbs -}}
  {{- with or (.Page.Resources.Get $u.Path) (resources.Get $u.Path) -}}
    {{- $src = .RelPermalink -}}
  {{- end -}}
{{- end -}}
<div class="Img__wrp"><img src="{{ $src }}"></div>

That’s the same approach we use with the embedded figure shortcode:

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