0

I am the static site generator Hugo with the theme Docsy, but I am having difficulty providing the correct path so Hugo can find my images?

I read Hugo's content organization will search for an image either in the Page Bundle or in the project's static directory. See Hugo Directory Structure: static.

I am using the Page Bundle organization for the images in my project.
The path to my images is: My_Hugo_Docsy_Project/content/en/docs/My_Page_Bundle/assets/image_file.jpg

I am using regular markdown to include the images, but this does not work:

![Image1](/assets/image_file.jpg)

I believe Docsy's multiple language feature (internationalization) is causing the hangup, which nests the content directory structure by language.

Dustin Ingram
  • 20,502
  • 7
  • 59
  • 82
Manchego
  • 755
  • 1
  • 6
  • 14

1 Answers1

0

Docsy's default config.toml, sets contentDir = "content/en".

Setting contentDir effectively changes the "site root" for Page Bundled resources like images. The "site root" directory is where Hugo would start to look for image_file.jpg.

#Hugo root directory when contentDir = "content/en"
`My_Hugo_Docsy_Project/content/en/

#Hugo root directory when contentDir = “content”
My_Hugo_Docsy_Project/content

So the image path in the markdown would be:

![Image1](/docs/My_Page_Bundle/assets/image_file.jpg)

Manchego
  • 755
  • 1
  • 6
  • 14
  • At a glance, I don't see how that config impacts you. You're using page bundles, so you should be able to reference the images with a relative path, e.g. `assets/image_file.jpg`. Note the dropped leading slash. Just a hunch though, not tested. – Andrei Mustata May 29 '20 at 10:49
  • tested the markup you suggested `assets/image_file.jpg` w/o the leading "/" it resulted in broken jpg. I definitely didn't anticipate the "contentDir" was adjusting the "site root" for Page Bundled resources. – Manchego May 29 '20 at 15:53