okkur / syna

Highly customizable open source theme for Hugo based static websites
https://syna.okkur.org/demo/
Apache License 2.0
250 stars 134 forks source link

Hugo: Error building site: failed to render pages #763

Closed schoettl closed 4 years ago

schoettl commented 4 years ago

Is this a BUG REPORT or FEATURE REQUEST?: bug

What happened: On my way to produce a minimal example for issue #759 , I encountered this problem:

I prepared the config.toml file to support a secondary language. I did not translate anything except the title in the config file.

I get this error (see also below):

render of "taxonomyTerm" failed: execute of template failed: template: _default/list.html:10:7: executing "_default/list.html"  ...

What you expected to happen: Hugo should generate the static site without errors.

How to reproduce it (as minimally and precisely as possible): see code block below and specifically this commit introducing the error: https://github.com/schoettl/syna-start/commit/af02744f612184500b8848a548b534ea02f93a2e

Anything else we need to know?: I did not understand the error message and I could not find solutions on the web.

Environment:

$ git clone --recurse-submodules https://github.com/schoettl/syna-start.git
$ git checkout bug-1
$ hugo
Building sites … WARN 2020/05/20 23:10:03 .File.Dir on zero object. Wrap it in if or with: {{ with .File }}{{ .Dir }}{{ end }}
ERROR 2020/05/20 23:10:03 render of "taxonomyTerm" failed: execute of template failed: template: _default/list.html:10:7: executing "_default/list.html" at <partial "helpers/fragments-renderer.html" (dict "page_scratch" .Scratch)>: error calling partial: execute of template failed: template: partials/helpers/fragments-renderer.html:18:8: executing "partials/helpers/fragments-renderer.html" at <partial (print "fragments/" .Params.fragment ".html") $context>: error calling partial: "/home/jakob/tmp/syna-start/themes/syna/layouts/partials/fragments/hero.html:106:12": execute of template failed: template: partials/fragments/hero.html:106:12: executing "partials/fragments/hero.html" at <.page.File.Dir>: error calling Dir: runtime error: invalid memory address or nil pointer dereference
ERROR 2020/05/20 23:10:03 render of "taxonomyTerm" failed: execute of template failed: template: _default/list.html:10:7: executing "_default/list.html" at <partial "helpers/fragments-renderer.html" (dict "page_scratch" .Scratch)>: error calling partial: execute of template failed: template: partials/helpers/fragments-renderer.html:18:8: executing "partials/helpers/fragments-renderer.html" at <partial (print "fragments/" .Params.fragment ".html") $context>: error calling partial: "/home/jakob/tmp/syna-start/themes/syna/layouts/partials/fragments/hero.html:106:12": execute of template failed: template: partials/fragments/hero.html:106:12: executing "partials/fragments/hero.html" at <.page.File.Dir>: error calling Dir: runtime error: invalid memory address or nil pointer dereference
Total in 517 ms
Error: Error building site: failed to render pages: render of "home" failed: execute of template failed: template: _default/list.html:10:7: executing "_default/list.html" at <partial "helpers/fragments-renderer.html" (dict "page_scratch" .Scratch)>: error calling partial: execute of template failed: template: partials/helpers/fragments-renderer.html:18:8: executing "partials/helpers/fragments-renderer.html" at <partial (print "fragments/" .Params.fragment ".html") $context>: error calling partial: "/home/jakob/tmp/syna-start/themes/syna/layouts/partials/fragments/hero.html:106:12": execute of template failed: template: partials/fragments/hero.html:106:12: executing "partials/fragments/hero.html" at <.page.File.Dir>: error calling Dir: runtime error: invalid memory address or nil pointer dereference
stp-ip commented 4 years ago

Try adding disableKinds = ["RSS", "taxonomy", "taxonomyTerm"] somewhere around version aka as a root level config.

This is not done in the starter repo, but probably should. Good catch. We should also look into taxonomy as well as RSS support again. @mpourismaiel

schoettl commented 4 years ago

Thank you @stp-ip ! I tried this, but now I get this error:

Error: Error building site: failed to render pages: render of "home" failed: execute of template failed: template: _default/list.html:10:7: executing "_default/list.html" at <partial "helpers/fragments-renderer.html" (dict "page_scratch" .Scratch)>: error calling partial: execute of template failed: template: partials/helpers/fragments-renderer.html:18:8: executing "partials/helpers/fragments-renderer.html" at <partial (print "fragments/" .Params.fragment ".html") $context>: error calling partial: "/home/jakob/projects/syna-start/themes/syna/layouts/partials/fragments/hero.html:106:12": execute of template failed: template: partials/fragments/hero.html:106:12: executing "partials/fragments/hero.html" at <.page.File.Dir>: error calling Dir: runtime error: invalid memory address or nil pointer dereference

Sorry, I don't understand this error message neither. Your config snippet was TOML, right?

stp-ip commented 4 years ago

Yes it was TOML. Will see that I get some time to dive into this, if @mpourismaiel doesn't before me ;)

mpourismaiel commented 4 years ago

Either we have fixed this issue while fixing something else or I can't replicate the issue. I tried the following:

The site builds successfully and can run the development server without any errors. The French page is empty as expected. I'm investigating the multi lingual issue happening as mentioned in #759 .

schoettl commented 4 years ago

Thanks! I'll test again on the weekend and close the issue, if it's solved!

mpourismaiel commented 4 years ago

@schoettl Please note I added params.DefaultContentLanguage = "en" after an edit. The documentation of multilingual mode contains this line but I forgot to add to my "steps to reproduce" comment above.

mpourismaiel commented 4 years ago

Sorry for the rapid fire of misinformation. I found the problem. Until we create a PR to fix the issue, please do the following to create a multilingual website using syna-start.

Since we added the index page without multilingual in mind, the structure doesn't allow multilingual mode to be setup. This change will allow the config to take effect without any issues.

Also if by the time you use syna-start, the themes/syna submodule is at #v0.17.0, please run git checkout #v0.17.2 in order to get the latest released version of Syna.

Again, sorry for the misinformation earlier. I didn't realize I was working in a modified state.

mpourismaiel commented 4 years ago

I pushed a fix and created a PR at https://github.com/okkur/syna-start/pull/36

Let us know if the problem persists.

schoettl commented 4 years ago

@mpourismaiel Thanks a lot for your work! So for, hugo runs again. I'll next test the other issue.

BTW, the command to create the _index/index.md file had the -e option missing.

 echo -e "+++\nheadless = true\n+++" > content/_index/index.md # create a headless page to fill the section page