Fix Hugo 0.160+ compatibility (deprecated site.Author, partial context in render hooks)#12
Open
splusq wants to merge 1 commit into
Open
Fix Hugo 0.160+ compatibility (deprecated site.Author, partial context in render hooks)#12splusq wants to merge 1 commit into
splusq wants to merge 1 commit into
Conversation
- Replace deprecated `site.Author` / `.Site.Author` with `site.Params.author` in head.html and 404.html. Author block now read from `[params.author]`, matching the example site's configuration. - Pass explicit `(dict)` context to all `partial "svg/..."` calls. In Hugo 0.160 a bare `partial NAME` no longer inherits a usable context inside render hooks (e.g. render-heading), causing `.class` lookups in svg partials to fail with "can't evaluate field class in type string". Tested against Hugo v0.160.1+extended.
|
@michenriksen please help review? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The theme currently fails to build with Hugo v0.156+ due to two breaking changes upstream:
site.Author/.Site.Authorwas removed. The example site already configures the author under[params.author], so the templates should readsite.Params.author(with a small guard so thehead.html<meta name=\"author\">tag falls back to thenamefield when the value is a map).partial \"svg/...\"calls fail inside render hooks. In Hugo 0.160 apartialcall with no second argument no longer inherits a usable context inside e.g.render-heading, so the SVG partials'.class | default ...expression errors withcan't evaluate field class in type string. Passing an explicit(dict)context restores the previous behavior.Fixed files:
layouts/partials/head.html—site.Author→site.Params.author(+ map fallback)layouts/404.html—.Site.Author.email→site.Params.author.emaillayouts/_default/_markup/render-heading.htmllayouts/_default/_markup/render-codeblock.htmllayouts/_default/_markup/render-codeblock-mermaid.htmllayouts/posts/list.html,layouts/notes/list.htmllayouts/partials/page/meta.html,layouts/partials/footer.htmlTest plan
hugobuilds clean againsthugo v0.160.1+extendedwith example-style[params.author]config🤖 Generated with Claude Code