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
![](https://is2-ssl.mzstatic.com/image/thumb/Purple116/v4/aa/20/7d/aa207d3d-c050-14b9-f084-9e0e2afaa646/AppIcon-Primary-0-1x_U007emarketing-0-7-0-85-220.png/460x0w.webp)
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.
![](https://is2-ssl.mzstatic.com/image/thumb/Purple116/v4/17/91/dc/1791dca0-047b-188c-23d3-00d7b3f33777/AppIcon-0-1x_U007emarketing-0-7-0-85-220.png/230x0w.webp)
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