Hugo troubleshooting: execute of template failed: can't give argument to non-function
render of “page” failed: execute of template failed: can’t give argument to non-function …
Symptom
After upgrade hugo from 0.62.2
to 0.79.1
and run hugo build got following error:
$ HUGO_ENV="production" hugo
Start building sites …
ERROR 2021/05/05 15:01:35 render of "page" failed: execute of template failed: template: blog/single.html:2:3: executing "main" at <.Render>: error calling Render: "foo.md:7:15": failed to execute template ["content"] v: ".../blog/content.html:7:15": execute of template failed: template: blog/content.html:7:15: executing "blog/content.html" at <(.Params.showLastmod) (ne $.Date $.Page.Lastmod)>: can't give argument to non-function .Params.showLastmod
Content of blog/content.html:7
:
{{ if and ((.Params.showLastmod) (ne $.Date $.Page.Lastmod)) }}
Looks like newer version of hugo
can not handle this condition.
Solution
Split the single condition check to multiple check:
{{ if .Params.showLastmod }}
{{ if ne $.Date $.Page.Lastmod }}
...
{{ end }}
{{ end }}
Related pages:
- Demystifying Hugo Shortcodes: Your Ultimate Guide
- Hugo: How to escape shortcode in markdown
- Add comments to Static blog like Hugo, Jekyll with Isso
- Tips on Hugo SEO
- Custom hugo RSS template
- Add git commit date as last update date in hugo page
OmniLock - Block / Hide App on iOS
Block distractive apps from appearing on the Home Screen and App Library, enhance your focus and reduce screen time.
DNS Firewall for iOS and Mac OS
Encrypted your DNS to protect your privacy and firewall to block phishing, malicious domains, block ads in all browsers and apps
Ad