I’m running into something I can’t explain and it’s a real hitch in the local dev process so hopefully someone understands why this is happening. I’m using Hugo Static Site Generator v0.61.0/extended darwin/amd64. I will be deploying to Netlify so I’m using a directory of images inside my ./content
directory so Netlify CMS can add image content there. I have a special image processing partial to process these images. Like so:
{{ with site.GetPage "images/uploads/_index.md" }}
{{ with .Resources.GetMatch $img }}
{{ $processed := .Resize $options }}
{{ if $doResponsive }}
{{ $processed2x := .Resize $options2x }}
<img src="{{ $processed2x.RelPermalink }}" width="{{ $processed.Width }}" height="{{
$processed.Height}}" alt="{{ $alt }}" srcset="{{ $processed.RelPermalink }}, {{
$processed2x.RelPermalink }} 2x">
{{ else }}
<img src="{{ $processed.RelPermalink }}" width="{{ $processed.Width }}" height="{{
$processed.Height}}" alt="{{ $alt }}">
{{ end }}
{{ end }}
{{ end }}
The reference is to a headless bundle at ./content/images/uploads/_index.md
.
This works fine with hugo server -w
, but any time that I git commit
and restart the server, no images render. If I then go into the content file and change ./content/images/uploads/_index.md
to ./content/images/uploads/index.md
, and change each reference in the partial from {{ with site.GetPage "images/uploads/_index.md" }}
to {{ with site.GetPage "images/uploads/index.md" }}
it works again. Until I git commit
and restart the server again. Then it is broken again. No images render. Execution doesn’t make it past site.GetPage
. I add the underscores back, it works. Until I git commit
and restart server. I’ve used this technique in two other projects and have never seen this before. I have no idea what’s going to happen upon deploy. Is there any way to avoid this?