1bl4z3r / hermit-V2

Continuing Hermit's legacy to be minimal and fast theme
https://1bl4z3r.github.io/hermit-V2/
MIT License
91 stars 38 forks source link

[BUG] - Error: error building site: render: failed to render pages #68

Closed 1buran closed 5 months ago

1buran commented 5 months ago

Describe the bug

I've upgraded hermit-V2 theme in my blog from v1.0.5 to the latest - v1.1.4 and the build had failure (detailed output in Terminal Output section), as my understanding the problem is here:

https://github.com/1bl4z3r/hermit-V2/blob/main/layouts/_default/baseof.html#L19

{{ $c_css := resources.Get . | resources.ExecuteAsTemplate "css/style.css" $rootCtx | toCSS | minify | fingerprint -}}

I'm surprised because as I see empty css/style.css exists in theme, maybe this is misconfiguration of hugo (my fault) or blog configuration conflict to theme, but all works find before (on v.1.0.5).

Could you please check it?

hermit changes

To Reproduce Have no idea, it seems the fastest way to reproduce the bug its just clone the blog and run hugo build:

  1. Clone https://github.com/1buran/blog (it is not large - 1 post and little bit of css)
  2. Run hugo build

Terminal Output

$ hugo -Dw --logLevel debug server
Watching for changes in /home/buran/projects/blog/{archetypes,assets,content,data,i18n,layouts,static,themes}
Watching for config changes in /home/buran/projects/blog/hugo.toml
Start building sites … 
hugo v0.123.7+extended linux/amd64 BuildDate=unknown

INFO  build:  step process substep collect files 3 files_total 3 duration 2.11206ms
INFO  build:  step process duration 2.368108ms
INFO  build:  step assemble duration 3.116779ms
INFO  static: syncing static files to / duration 15.526749ms
INFO  deprecated: .Site.DisqusShortname was deprecated in Hugo v0.120.0 and will be removed in a future release. Use .Site.Config.Services.Disqus.Shortname instead.
INFO  build:  step render pages 13 content 10 duration 108.256449ms
INFO  build:  step postProcess duration 8.529µs
INFO  build:  duration 114.262578ms
Built in 115 ms
Error: error building site: render: failed to render pages: render of "page" failed: "/home/buran/projects/blog/themes/hermit-v2/layouts/_default/baseof.html:19:40": execute of template failed: template: _default/single.html:19:40: executing "_default/single.html" at <resources.ExecuteAsTemplate>: error calling ExecuteAsTemplate: type <nil> not supported in Resource transformations

Expected behavior Missed css/style.css should not be cause build failure.

Hugo (please complete the following information):

Additional context Archlinux

1bl4z3r commented 5 months ago

Hi @1buran,

That indeed is strange. To give some context so that we are on same page

I'm surprised because as I see empty css/style.css exists in theme

style.css is referring to single stylesheet that is used by hermit. It adds all styles from different sass into one

Im not sure what does this mean, answered based on hugo version suffix

This is for Windows users specifically. As you are Linux user, nothing to do here

TL;DR, I have to check this. Expect a response within 24 hrs

P.S. Thanks for linking source

1bl4z3r commented 5 months ago

Hi @1buran,

It looks like the error you had provided can't be recreated on my end. It seems like something in hugo.toml is changed which totally breaks the generation.

sh-5.2$ hugo_extended_0.125.3_linux-amd64/hugo -Dw --logLevel debug server

Watching for changes in /blog/{archetypes,assets,content,layouts,static}
Watching for config changes in /blog/hugo.toml
Start building sites … 
hugo v0.125.3-474c4c02212cf97712c6fbf4159c68822ea6e078+extended linux/amd64 BuildDate=2024-04-22T17:18:35Z VendorInfo=gohugoio

INFO  build:  step process substep collect files 2 files_total 2 duration 887.345µs
INFO  build:  step process duration 1.005154ms
INFO  build:  step assemble duration 673.143µs
WARN  found no layout file for "html" for kind "home": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN  found no layout file for "html" for kind "taxonomy": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN  found no layout file for "html" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
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.
WARN  found no layout file for "html" for kind "section": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
INFO  build:  step render substep pages site en outputFormat html duration 1.781122ms
INFO  static: syncing static files to / duration 9.94762ms
INFO  build:  step render substep pages site en outputFormat rss duration 34.284611ms
INFO  build:  step render pages 7 content 4 duration 36.327322ms
INFO  build:  step postProcess duration 11.274µs
INFO  build:  duration 38.22242ms

                   | EN  
-------------------+-----
  Pages            |  7  
  Paginator pages  |  0  
  Non-page files   |  0  
  Static files     | 11  
  Processed images |  0  
  Aliases          |  0  
  Cleaned          |  0  

Built in 40 ms
Environment: "development"
Serving pages from disk
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at //localhost:1313/ (bind address 127.0.0.1) 
Press Ctrl+C to stop

Also no .html files are being generated on build.

blog/public$ find . -type f -name "*.*"
./android-chrome-192x192.png
./android-chrome-512x512.png
./apple-touch-icon.png
./browserconfig.xml
./css/about.css
./favicon-16x16.png
./favicon-32x32.png
./favicon.ico
./mstile-150x150.png
./safari-pinned-tab.svg
./site.webmanifest
./sitemap.xml
./categories/index.xml
./tags/index.xml
./tags/emacs/index.xml
./tags/golang/index.xml
./images/2023-11-05-235956.png
./images/2023-11-29-185853.png
./posts/index.xml
./index.xml
1bl4z3r commented 5 months ago

Hi @1buran again

Found the bug. You had put about.css in static directory.

According to the Readme, you should've put the custom css file in assets so that Hugo can fetch them.

Moving the relevant css file to assets fixed the issue. Also find updated file structure. Note that I have moved about.css from static/css to assets/about-css

./assets/about-css/about.css

blog$ find . -type f -name "*.*"|grep -v 'themes\|.git\|public\|resources'

./archetypes/default.md
./assets/css/custom.css
./assets/images/2023-11-05-235956.png
./assets/images/2023-11-29-185853.png
./assets/about-css/about.css
./layouts/partials/extra-head.html
./content/about.md
./content/posts/effective-update-emacs-straight-packages.md
./hugo.toml
./static/android-chrome-192x192.png
./static/android-chrome-512x512.png
./static/apple-touch-icon.png
./static/browserconfig.xml
./static/favicon.ico
./static/favicon-16x16.png
./static/favicon-32x32.png
./static/mstile-150x150.png
./static/safari-pinned-tab.svg
./static/site.webmanifest
./.hugo_build.lock

Hoping to get an update from you

1buran commented 5 months ago

Hey @1bl4z3r! Nice catch!

I'm totally forgot about custom css in about page:

---                              
custom_css: ["/css/about.css"]   
---                              

Yeah, you are right, this file should be inside the assets dir, it seems I placed it there (to static/css) when i tried to enabled it and placement inside assets didn't cause any effect (in old version of hugo or hermet theme).

Thanks for all your help!

P.S. Movement about.css to assets dirs solved this puzzle, thanks!