Images in Hugo blog: TL;DRs
Page content
Render static images
- Place your image file under
static
directory. E.g.,static/cat1/my_image.png
. - Refer the image without
static
. e.g.,/cat1/my_image.png
.

Add captions
Using Markdown render hooks
The main idea is, we can overwrite how to convert image lines in markdown into HTML by create the template file layouts/_default/_markup/render-image.html
.
I copied the logic from this page (Thank you, Sebastian!)
If
title
is specified, render by<figcaption>
tag. Otherwise, just ignore it.
{{ if .Title }}
<figure>
<img src="{{ .Destination | safeURL }}" alt="{{ .Text }}">
<figcaption>{{ .Title }}</figcaption>
</figure>
{{ else }}
<img src="{{ .Destination | safeURL }}" alt="{{ .Text }}">
{{ end }}