For some days now my site is not compiling on Netlify. Running hugo
and hugo server
locally does not throw any errors and is building the site as expected.
Running hugo
on Netlify works normal until Hugo is running. It then times out with the following error:
10:56:27 PM: Executing user command: hugo --gc --minify
10:56:27 PM: Building sites …
10:57:05 PM: Canceling deploy
10:57:11 PM: Total in 43741 ms
10:57:11 PM: Error: Error building site: "/opt/build/repo/content/post/2019/06/shut-up/index.md:1:1": timed out initializing value. This is most likely a circular loop in a shortcode
10:57:11 PM: Execution cancelled
The error hides in the scrolling part of the log above.
The .md file uses one single shortcode that is used in nearly all posts for article images:
{{< img src="gelaber" >}}Vögel sind diskussionsfreudiger als ihr (<a href="https://unsplash.com/photos/4AmyOdXZAQc">Photo von Wynand van Poortvliet</a>){{< /img >}}
There is a gelaber.jpg in the same folder as the .md file and no frontmatter markup.
My img
shortcode looks like this (I left the comments in just in case they cause the issue:
{{/*
see
https://laurakalbag.com/processing-responsive-images-with-hugo/
https://discourse.gohugo.io/t/easy-way-to-serve-responsive-images-with-hugo/16184
https://www.adamwills.io/blog/responsive-images-hugo/
https://gohugo.io/content-management/image-processing/
*/}}
{{/* get file that matches the filename as specified as src="" in shortcode */}}
{{ $src := .Page.Resources.GetMatch (printf "*%s*" (.Get "src")) }}
{{/* set image sizes, these are hardcoded for now, x dictates that images are resized to this width */}}
{{ $smallw := default "510x" }}
{{ $mediumw := default "690x" }}
{{ $largew := default "730x" }}
{{/* resize the src image to the given sizes */}}
{{ .Scratch.Set "small" ($src.Resize $smallw) }}
{{ .Scratch.Set "medium" ($src.Resize $mediumw) }}
{{ .Scratch.Set "large" ($src.Resize $largew) }}
{{/* add the processed images to the scratch */}}
{{ $small := .Scratch.Get "small" }}
{{ $medium := .Scratch.Get "medium" }}
{{ $large := .Scratch.Get "large" }}
{{/* only use images smaller than or equal to the src (original) image size, as Hugo will upscale small images */}}
{{/* set the sizes attribute to (min-width: 35em) 690px, 100vw unless overridden in shortcode */}}
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}>
{{ with .Get "link"}}<a href="{{.}}">{{ end }}
<img
{{ with .Get "sizes" }}sizes='{{.}}'{{ else }}sizes="(min-width: 35em) 720px, 100vw"{{ end }}
srcset='
{{ if ge $src.Width "510" }}
{{ with $small.RelPermalink }}, {{.}} 510w{{ end }}
{{ end }}
{{ if ge $src.Width "690" }}
{{ with $medium.RelPermalink }}, {{.}} 690w{{ end }}
{{ end }}
{{ if ge $src.Width "720" }}
{{ with $large.RelPermalink }}, {{.}} 720w {{ end }}
{{ end }}'
{{ if .Get $medium }}
src="{{ $medium.RelPermalink }}"
{{ else }}
src="{{ $src.RelPermalink }}"
{{ end }}
{{ with .Get "alt" }}alt='{{.}}'{{ end }}>
{{ if .Get "link"}}</a>{{ end }}
{{ with .Inner }}
<figcaption>{{ . }}</figcaption>
{{ end }}
</figure>
Who (Hugo or Netlify) is causing the error message about a possible loop? And what is causing the issue?
It’s weird that the issue comes up only on Netlify, so my idea is that the image can’t be found there due to some different file system types or used lookup methods?
The repo can be found on Github https://github.com/davidsneighbour/samui-samui.de