Should all the images be in the static folder, or can they be post in any folder?
No and yes.
More info on that in the documentation under Page bundles
and
It depends on the theme, the baseURL
, etc.
If I were starting from scratch, creating my own layouts/themeβ¦
Images related to a single page should be placed in a page bundle:
content/
βββ posts/
β βββ post-1/
β β βββ c.jpg <-- page resource
β β βββ d.jpg <-- page resource
β β βββ index.md
β βββ post-2.md
β βββ _index.md
βββ _index.md
Images that can be used anywhere on the site should be placed in the assets directory:
assets/
βββ images/
βββ a.jpg <-- global resource
βββ b.jpg <-- global resource
And to make this setup work when adding images to your Markdown, enable Hugoβs embedded link and image render hooks in your site configuration:
[markup.goldmark.renderHooks.image]
enableDefault = true
[markup.goldmark.renderHooks.link]
enableDefault = true
The content/posts/post-1/index.md file would look something like this:


Note that Hugoβs embedded link and image render hooks are automatically enabled for multilingual single-host sites.
Shouldnβt another kitten
refer to a.jpg
or b.jpg
(from the page bundle)? Or perhaps using a/b
for assets
and c/d
for the bundle would make the approach clearer.
The file names are irrelevant. I have fixed the tree diagrams above.
Resolution of the Markdown destinations is performed by the render hooks. The render hook documentation describes precedence.