jpanther / congo

A powerful, lightweight theme for Hugo built with Tailwind CSS.
https://jpanther.github.io/congo/
MIT License
1.19k stars 313 forks source link

Images aren't showing when used in the non-default language #898

Closed bugok closed 2 months ago

bugok commented 2 months ago

Issue description

I have a website using congo. When adding image references to the non-default language - images aren't showing up in the post.

Repro steps: clone my repo, with the submodule:

git clone --recursive git@github.com:bugok/blog dksjbkdsjb

Run hugo locally, show drafts:

hugo serve -D

See that http://localhost:1313/he/posts/kindle_hebrew_font/ doesn't show the image:

Screenshot 2024-06-14 at 9 31 28

When running the build command, I don't see the images in the public directory, alongside the html file:

hugo -D
...
$ ls -l public/he/posts/kindle_hebrew_font
total 56
drwxr-xr-x  3 noamler  staff     96 Jun 14 09:46 ./
drwxr-xr-x  8 noamler  staff    256 Jun 14 09:46 ../
-rw-r--r--  1 noamler  staff  27947 Jun 14 09:46 index.html

For the English site - images are showing up properly.

When I change the default language to Hebrew in config, it does work:

$ git diff
diff --git a/config/_default/config.toml b/config/_default/config.toml
index 926ab6c..5304317 100644
--- a/config/_default/config.toml
+++ b/config/_default/config.toml
@@ -4,7 +4,7 @@

 # baseURL = "https://your_domain.com/"
 baseUrl = "https://www.noamlerner.com/"
-defaultContentLanguage = "en"
+defaultContentLanguage = "he"
 paginate = 10
 theme = 'congo'
 enableRobotsTXT = true

Then, loading http://localhost:1313/posts/kindle_hebrew_font/ does show the image:

Screenshot 2024-06-14 at 9 36 42

Theme version

v2.8.2

Hugo version

hugo v0.127.0+extended darwin/arm64 BuildDate=2024-06-05T10:27:59Z VendorInfo=brew

Which browser rendering engines are you seeing the problem on?

Chromium (Google Chrome, Microsoft Edge, Brave, Vivaldi, Opera, etc.)

URL to sample repository or website

https://github.com/bugok/blog

Hugo output or build error messages

$ hugo
Start building sites …
hugo v0.127.0+extended darwin/arm64 BuildDate=2024-06-05T10:27:59Z VendorInfo=brew

                   | EN  | HE
-------------------+-----+-----
  Pages            |  93 | 15
  Paginator pages  |   4 |  0
  Non-page files   |  43 |  8
  Static files     |   7 |  7
  Processed images | 140 |  0
  Aliases          |  32 |  2
  Cleaned          |   0 |  0

Total in 215 ms
bugok commented 2 months ago

This seems to be very similar to this issue: https://github.com/gohugoio/hugo/issues/12163

But, not quite the same.

Maybe this is a hugo issue, and not a theme issue?

bugok commented 2 months ago

OK, this is my misunderstanding how to do multi language images in hugo.

Looking at the documentation: https://gohugo.io/content-management/multilingual/#page-bundles, I found that I needed to rename the image files with the language suffix.

Meaning, if I have an image.jpg, I would need to rename it to image.he.jpg. When referencing this image in markdown, reference it as image.jpg