hugo-PaperMod: Missing template definitions breaks production builds in Hugo v0.146.0+
What you’d like to propose?
Hi!
In the latest version of PaperMod, the following templates are referenced inside _partials/head.html:
{{ template "partials/templates/opengraph.html" . }}
{{ template "partials/templates/twitter_cards.html" . }}
{{ template "partials/templates/schema_json.html" . }}
However, these templates are not defined in the theme (using {{ define … }}), which causes the Hugo build to fail in production mode:
Error: html/template:_partials/head.html:155:13: no such template "partials/templates/twitter_cards.html"
This is especially confusing because it only triggers in production (i.e., hugo.IsProduction == true), so users upgrading from an older version may not notice the issue until CI breaks.
Suggested Fix:
- Provide empty stub templates for these in layouts/partials/templates/, e.g.:
{{ define "partials/templates/twitter_cards.html" }}{{ end }}
That way, users can override them if needed, but the build won’t fail by default.
Thanks for the great theme!
Code of Conduct
- I agree to follow this project’s Code of Conduct
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 17
- Comments: 22 (16 by maintainers)
Commits related to this issue
- fix build failure due to template definition thanks to @jmooring in https://github.com/adityatelange/hugo-PaperMod/issues/1719#issuecomment-2797327929 — committed to ma08/hugo-PaperMod by ma08 2 years ago
- 与 v0.146.0 及更高版本兼容 https://github.com/adityatelange/hugo-PaperMod/issues/1719#issuecomment-2797327929 — committed to cuddly-guacamole/hugo-PaperMod by cuddly-guacamole 2 years ago
- Fix breakage with hugo update https://github.com/adityatelange/hugo-PaperMod/issues/1719#issuecomment-2797327929 — committed to miallo/hugo-PaperMod by miallo 2 years ago
- Revert to Hugo version 0.145.0 because of unsolved issues with PaperMod https://github.com/adityatelange/hugo-PaperMod/issues/1719 — committed to marbar1/recipes by marbar1 2 years ago
These are the required theme changes to be compatible with v0.146.0 and later.
Yes, thank you for that. I am just not happy with how hugo handles sudden breaking changes.
same issue as well, need back to hugo 0.145.0, template system has been changed since 0.146.0
Sorry, still an issue: google-analytics.html is missing. hugo server will work with the previous commit changes, but running hugo itself on a site fails without google-analytics.html. I removed the line requiring google-analytics.html and was able to run hugo against PaperMod.
I sent #1726, though I guess there’s no CI so things aren’t exactly checked.
Yeah, I’ve been using it for a year, and I’m surprised how quickly they introduce changes that break backward compatibility. It seems like having a stable version isn’t something they prioritize 😅
Things are not settled yet and decisions are yet to be made on Hugo’s side and https://github.com/gohugoio/hugo/issues/13553 is still in progress. And we also have no backwards compatibility. One maintainer comments the patch (with a future implementation) instead of a PR. 😕
Ideally, CI would build the site itself (demo site?) with both the minimum and latest versions of hugo. Or at least, the minimum and some kind of scheduled job that runs periodically to show if the site works with the latest version, or something.
I am happy to send a PR to propose something.