LoveIt icon indicating copy to clipboard operation
LoveIt copied to clipboard

[BUG] Adapt hugo 0.146

Open faimin opened this issue 7 months ago • 14 comments

Describe the bug 描述你遇到的错误

Hugo reimplement template system in 0.146, and build failed with the new template system https://github.com/gohugoio/hugo/pull/13541

hugo v0.146.3-05ef8b713a3c091bfca7a3543ed016c64b3c6f88+extended linux/amd64 BuildDate=2025-04-12T17:21:50Z VendorInfo=gohugoio

Total in 54 ms
Error: error building site: html/template:_markup/render-codeblock-mermaid.html:[6](https://github.com/faimin/faimin.github.io/actions/runs/14448076537/job/40513552917#step:5:7):1[7](https://github.com/faimin/faimin.github.io/actions/runs/14448076537/job/40513552917#step:5:8): no such template "_default/_markup/render-codeblock.html"
Error: Process completed with exit code 1.

Expected behavior 期待的行为

build success

Screenshots 屏幕截图

Build Environment 构建环境

  • OS: Ubuntu
  • Theme commit [ c8b65127 ]
  • Hugo version [ 0.146.3 ]

Please try to use Hugo extended version before opening the issue. 请在创建 issue 之前先尝试使用 Hugo extended 版本构建.

Preview Environment 预览环境

  • OS: [macOS]
  • Browser type/version [ Edge 135.0.3179.73 ]

Additional Information 补充信息

hugo #13541

Configuration files or front matter code... 配置文件或者前置参数的代码...

faimin avatar Apr 14 '25 14:04 faimin

i've been seeing variants on this pop up with the latest hugo builds as well. i haven't had a chance to really root cause what's going on here.

e.g.:

Error: html/template:_partials/internal/x.html:1:13: no such template "_internal/shortcodes/x.html"

i was able to work around these errors in the near term by creating overrides in $HUGO_DIR/layouts/partials/internal that remove the hugo.Version checks and only point at the _internal/... templates.

sulrich avatar Apr 14 '25 17:04 sulrich

Same issue here

hugo version
hugo v0.147.0-7d0039b86ddd6397816cc3383cb0cfa481b15f32+extended linux/amd64 BuildDate=2025-04-25T15:26:28Z VendorInfo=gohugoio
hugo server
Error: html/template:_markup/render-codeblock-mermaid.html:6:17: no such template "_default/_markup/render-codeblock.html"

YtachY avatar Apr 27 '25 13:04 YtachY

Same issue here

hugo version
hugo v0.147.0-7d0039b86ddd6397816cc3383cb0cfa481b15f32+extended linux/amd64 BuildDate=2025-04-25T15:26:28Z VendorInfo=gohugoio
hugo server
Error: html/template:_markup/render-codeblock-mermaid.html:6:17: no such template "_default/_markup/render-codeblock.html"

Got the same error!

johnnyhwu avatar May 01 '25 15:05 johnnyhwu

Got the same error on a fresh install.

appetrosyan avatar May 12 '25 17:05 appetrosyan

i was able to work around these errors in the near term by creating overrides in $HUGO_DIR/layouts/partials/internal that remove the hugo.Version checks and only point at the _internal/... templates.

Could you share how you did that?

skynetcat avatar May 14 '25 12:05 skynetcat

I just went and compiled an old version of hugo. I think it's the best workaround we have here.

Steps

  1. Uninstall hugo
  2. Make sure go is installed and add go binaries into your PATH. In my case on Linux in ~/.bashrc:
export PATH="$PATH:$HOME/go/bin"
  1. Install Hugo v0.145.0 (The last version LoveIt supports)
go install github.com/gohugoio/[email protected]

and enjoy till we can have a more up-to-date version of this cool theme.

skynetcat avatar May 14 '25 19:05 skynetcat

there's a writeup at https://gohugo.io/templates/new-templatesystem-overview/ that outlines the changes that are necessary to make layouts resolution work in 0.146+.

i updated things to align with the new directory structure. along the lines of the following:

% tree --charset unicode layouts
layouts
|-- _default
|-- _partials             
|   |-- head               
|   |   `-- link.html
|   |-- internal
|   |   |-- x_simple.html       # i stubbed this in
|   |   `-- x.html              # ibid
|   `-- single
|       `-- footer.html
|-- _shortcodes
|   |-- gfp.html
|   |-- gist.html
|   |-- mastodon.html
|   `-- spotify.html
|-- index.jsonfeed.json
|-- links
|   `-- single.html
|-- list.jsonfeed.json
|-- summary.html
`-- til
    `-- single.html

this eliminated the build errors for me.

now i get the following warning. which i will deal with separately.

Start building sites …
hugo v0.147.3+extended+withdeploy darwin/arm64 BuildDate=2025-05-12T12:25:03Z VendorInfo=brew

WARN  Current environment is "development". The "comment system", "CDN" and "fingerprint" will be disabled.
WARN  当前运行环境是 "development". "评论系统", "CDN" 和 "fingerprint" 不会启用.
WARN  found no layout file for "html" for kind "term": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

                   | EN
-------------------+------

sulrich avatar May 14 '25 19:05 sulrich

there's a writeup at https://gohugo.io/templates/new-templatesystem-overview/ that outlines the changes that are necessary to make layouts resolution work in 0.146+.

i updated things to align with the new directory structure. along the lines of the following:

% tree --charset unicode layouts
layouts
|-- _default
|-- _partials             
|   |-- head               
|   |   `-- link.html
|   |-- internal
|   |   |-- x_simple.html       # i stubbed this in
|   |   `-- x.html              # ibid
|   `-- single
|       `-- footer.html
|-- _shortcodes
|   |-- gfp.html
|   |-- gist.html
|   |-- mastodon.html
|   `-- spotify.html
|-- index.jsonfeed.json
|-- links
|   `-- single.html
|-- list.jsonfeed.json
|-- summary.html
`-- til
    `-- single.html

this eliminated the build errors for me.

now i get the following warning. which i will deal with separately.

Start building sites …
hugo v0.147.3+extended+withdeploy darwin/arm64 BuildDate=2025-05-12T12:25:03Z VendorInfo=brew

WARN  Current environment is "development". The "comment system", "CDN" and "fingerprint" will be disabled.
WARN  当前运行环境是 "development". "评论系统", "CDN" 和 "fingerprint" 不会启用.
WARN  found no layout file for "html" for kind "term": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

                   | EN
-------------------+------

Thank you :)

skynetcat avatar May 14 '25 20:05 skynetcat

I've fixed this issue in my site with this commit. Feel free to check it for reference and see if it helps.

hakula139 avatar May 24 '25 14:05 hakula139

I've fixed this issue in my site with this commit. Feel free to check it for reference and see if it helps.

any chance you're opening a pull request to get these upstreamed? 😉

sulrich avatar May 28 '25 14:05 sulrich

Can confirm sulrich's fork makes some things work again (MermaidJS code fences + hugo@latest). The {{<mermaid>}} shortcode doesn't seem to work, using code fences does. Dark theme CSS is not ideal and could be improved for visibility (lines are dark gray on dark background, etc.).

titpetric avatar Jun 04 '25 18:06 titpetric

  • i forked this to address my needs specifically. if this gets resolved more broadly, i'll happily go back to whatever's upstream.
  • i ripped out the mermaid bits from the current theme as it didn't seem to be consistently triggering the rendering at all. i adopted the fenced code approach a la the hugo docs. i've given zeero attention as to how to theme this for dark mode. creating a custom shortcode for this seems like the right move to ensure that this gets addressed.

given the significant filesystem restructuring that hugo imposes on things here, i think this really requires a new release to appropriately fix things. i don't know what the appetite for the maintainers is for addressing this.

sulrich avatar Jun 05 '25 13:06 sulrich

For what little context I can give:

  1. this commit seems to do the same for LoveIt master (not part of 0.3.0): https://github.com/dillonzq/LoveIt/commit/859f5745116c0a750bbcb44146b5221145292d47
  2. the code blocks fenced with mermaid correctly render into a div
  3. https://github.com/dillonzq/LoveIt/blob/master/layouts/partials/assets.html#L130 is not triggering the JS include ending up in an undefined mermaid error
  4. hugo 145-147 changed the api and deprecated .Scratch.Get

Not a fan of {{<mermaid>}} but either way, same conclusion as yours @sulrich , it doesn't trigger rendering

titpetric avatar Jun 05 '25 17:06 titpetric

export PATH="$PATH:$HOME/go/bin"

I solved it by this way.

OnClickListener2048 avatar Jun 09 '25 01:06 OnClickListener2048

I'm having the same issue with 0.146.0 hugo extend version. According to perplexity, that file should not be in the themes directory but in the /layouts. Will this be fixed soon?

raphideb avatar Jul 09 '25 10:07 raphideb

I'm facing the same issue:

hugo server -D -M
WARN  deprecated: the ":filename" permalink token was deprecated in Hugo 0.144.0 and will be removed in a future release. Use ":contentbasename" instead.
Error: html/template:_markup/render-codeblock-goat.html:6:17: no such template "_default/_markup/render-codeblock.html"
hugo version
hugo v0.148.1-98ba786f2f5dca0866f47ab79f394370bcb77d2f darwin/arm64 BuildDate=2025-07-11T12:56:21Z VendorInfo=gohugoio

rguske avatar Jul 14 '25 17:07 rguske

I mitigate the issue differently. I create a local layouts/partials/shim.html (name of the file doesn't matter) with the following content:

{{ define "_default/_markup/render-codeblock.html" }}
{{- template "_markup/render-codeblock.html" . -}}
{{ end }}

{{ define "_internal/shortcodes/x.html" }}
{{- partial "shortcodes/x.html" . -}}
{{ end }}

{{ define "_internal/shortcodes/x_simple.html" }}
{{- partial "shortcodes/x_simple.html" . -}}
{{ end }}

{{ define "_internal/shortcodes/instagram.html" }}
{{- partial "shortcodes/instagram.html" . -}}
{{ end }}

jkroepke avatar Aug 24 '25 01:08 jkroepke

I use trae.ai auto fixed loveit theme version . See this article. https://www.ffeeii.com/trae-solo-skill.html

lifeibest avatar Aug 27 '25 05:08 lifeibest

I will update the patch soon to fix this problem, but need to ensure the compatibility of the old version first.

dillonzq avatar Sep 07 '25 12:09 dillonzq

We need to make modifications to the config.toml configuration file so that it can support tags and categories.

  • config.toml
[Permalinks]
  posts = ":contentbasename"

[taxonomies]
  tag = "tags"
  category = "categories"
Image
cp layouts/taxonomy/list.html layouts/_default/term.html

jetsung avatar Sep 17 '25 09:09 jetsung