My gallery.html shortcode works well locally, but some(?) pages using the shortcode do not render on Netlify—yet without an error message. The .Content part of these pages is missing entirely.
Have you any ideas?
Thank you very much!
{{ with $.Get "title" }}<h2>{{ . }}</h2>{{ end }}
<div class="gallery">
{{ range $image := (.Page.Resources.ByType "image").Match (printf "%s*" (.Get "src")) }}
{{ $image := .Fill "450x300" }}
<figure><img src="{{ $image.RelPermalink }}" alt="{{ $image.Name }}" />{{ with .Params.caption }}<figcaption>{{ . }}</figcaption>{{ end }}</figure>
{{ end }}
</div>
{{ with .Inner }}{{ . }}{{ end }}
This is the problem with posting snippets: I don’t see any “.Content” in your example above, so I’m obviously missing out on something.
In general, I can say that resources/image processing ala what you do above works great on Netlify. We use it exstensively for the themes and the docs site.
The project is not public, yet. Otherwise I would have pointed to the repository.
We have tested everything for hours and finally had to (temporarily?) move away from Netlify. The local build works without any issues (and the gallery shortcode like a charm).
I ran into issues with image processing as well, tho I don’t know if yours are related.
The hugo binaries in my case are in the repo under bin/ from the starter template I used.
Everything worked fine after I replaced those with the newest version of Hugo and updated my npm dependencies.
I encourage you to look through you build script to figure out what version of Hugo is used in production. Maybe insert a hugo version; before Hugo build.
Now, the same error occured in a project that does not use NPM, Gulp or anything else—just Hugo.
Deploy log says:
Installing Hugo 0.40.3
Executing user command: hugo version ; hugo
Hugo Static Site Generator v0.40.3 linux/amd64 BuildDate: 2018-05-09T07:46:33Z
…
Build script success
I ran into this exact problem today, too. Netlify would not build the .Content for a post that uses a shortcode for images – though it worked fine locally.
Tried using the verbose build command (hugo -v) on Netlify, which gave me a clue to what was going on:
WARNING: Timed out creating content for page “blog/that-darn-post/index.md” (.Content will be empty). This is most likely a circular shortcode content loop that should be fixed. If this is just a shortcode calling a slow remote service, try to set “timeout=20000” (or higher, value is in milliseconds) in config.toml
So I did just that, and now it works perfectly. I have a lot of resizing going on in my shortcode, and suspect the Netlify-build times out because the server can’t do all the image processing fast enough. (Wild guess.)