imfing / hextra

🔯 Modern, batteries-included Hugo theme for creating beautiful doc, blog and static websites
https://imfing.github.io/hextra/
MIT License
584 stars 146 forks source link

Got a template error when following the Getting Started instructions #64

Closed billux closed 1 year ago

billux commented 1 year ago

Tested using the latest version of hugo (extended version) running in docker:

$ hugo version
hugo v0.111.3-5d4eb5154e1fed125ca8e9b5a0315c4180dab192+extended linux/amd64 BuildDate=2023-03-12T11:40:50Z VendorInfo=hugoguru

Steps to reproduce: just follow the Getting Started instructions:

$ hugo new site my-site --format=yaml
$ cd my-site/
$ hugo mod init github.com/username/my-site
$ hugo mod get github.com/imfing/hextra
$ cat <<EOT >>config.yaml
module:
  imports:
    - path: github.com/imfing/hextra
EOT
$ hugo new content/_index.md
$ hugo new content/docs/_index.md
$ hugo server --buildDrafts --disableFastRender

The hugo server throws:

Start building sites … 
hugo v0.111.3-5d4eb5154e1fed125ca8e9b5a0315c4180dab192+extended linux/amd64 BuildDate=2023-03-12T11:40:50Z VendorInfo=hugoguru
Error: Error building site: failed to render pages: render of "section" failed: "/tmp/modules/filecache/modules/pkg/mod/github.com/imfing/hextra@v0.2.8/layouts/section/section.rss.xml:20:17": execute of template failed: template: section/section.rss.xml:20:17: executing "section/section.rss.xml" at <site>: can't evaluate field LanguageCode in type *langs.Language
Built in 43 ms

The config.yaml:

$ cat config.yaml 
baseURL: http://example.org/
languageCode: en-us
title: My New Hugo Site
module:
  imports:
    - path: github.com/imfing/hextra
imfing commented 1 year ago

I'll look into that. In the meantime can you try using the template repository instead?

https://github.com/imfing/hextra-starter-template

billux commented 1 year ago

Ok so using the template repository works.

First, I realize that the latest docker image for hugo doesn't match the latest hugo version (open issue here).

The hugo version used in the Github Action of your template is the 0.117.0 (not the latest one, but still more recent than the latest hugo docker image, which is 0.111.3).

If I try to clone the repo created from the template and run the build locally (with hugo 0.111.3 in docker), hugo serve throws new errors:

$ hugo serve
hugo: downloading modules …
hugo: collected modules in 5157 ms
Start building sites … 
hugo v0.111.3-5d4eb5154e1fed125ca8e9b5a0315c4180dab192+extended linux/amd64 BuildDate=2023-03-12T11:40:50Z VendorInfo=hugoguru
ERROR 2023/09/19 15:59:48 render of "page" failed: "/tmp/modules/filecache/modules/pkg/mod/github.com/imfing/hextra@v0.2.7/layouts/docs/single.html:4:7": execute of template failed: template: docs/single.html:4:7: executing "main" at <partial "toc.html" .>: error calling partial: "/tmp/modules/filecache/modules/pkg/mod/github.com/imfing/hextra@v0.2.7/layouts/partials/toc.html:28:42": execute of template failed: template: partials/toc.html:28:42: executing "partials/toc.html" at <urls>: can't evaluate field JoinPath in type interface {}
ERROR 2023/09/19 15:59:48 render of "page" failed: "/tmp/modules/filecache/modules/pkg/mod/github.com/imfing/hextra@v0.2.7/layouts/docs/single.html:4:7": execute of template failed: template: docs/single.html:4:7: executing "main" at <partial "toc.html" .>: error calling partial: "/tmp/modules/filecache/modules/pkg/mod/github.com/imfing/hextra@v0.2.7/layouts/partials/toc.html:28:42": execute of template failed: template: partials/toc.html:28:42: executing "partials/toc.html" at <urls>: can't evaluate field JoinPath in type interface {}
ERROR 2023/09/19 15:59:48 render of "section" failed: "/tmp/modules/filecache/modules/pkg/mod/github.com/imfing/hextra@v0.2.7/layouts/docs/list.html:4:7": execute of template failed: template: docs/list.html:4:7: executing "main" at <partial "toc.html" .>: error calling partial: "/tmp/modules/filecache/modules/pkg/mod/github.com/imfing/hextra@v0.2.7/layouts/partials/toc.html:28:42": execute of template failed: template: partials/toc.html:28:42: executing "partials/toc.html" at <urls>: can't evaluate field JoinPath in type interface {}
ERROR 2023/09/19 15:59:48 render of "section" failed: "/tmp/modules/filecache/modules/pkg/mod/github.com/imfing/hextra@v0.2.7/layouts/docs/list.html:4:7": execute of template failed: template: docs/list.html:4:7: executing "main" at <partial "toc.html" .>: error calling partial: "/tmp/modules/filecache/modules/pkg/mod/github.com/imfing/hextra@v0.2.7/layouts/partials/toc.html:28:42": execute of template failed: template: partials/toc.html:28:42: executing "partials/toc.html" at <urls>: can't evaluate field JoinPath in type interface {}
Error: Error building site: failed to render pages: render of "page" failed: "/tmp/modules/filecache/modules/pkg/mod/github.com/imfing/hextra@v0.2.7/layouts/_default/single.html:4:7": execute of template failed: template: _default/single.html:4:7: executing "main" at <partial "toc.html" .>: error calling partial: "/tmp/modules/filecache/modules/pkg/mod/github.com/imfing/hextra@v0.2.7/layouts/partials/toc.html:28:42": execute of template failed: template: partials/toc.html:28:42: executing "partials/toc.html" at <urls>: can't evaluate field JoinPath in type interface {}
Built in 53 ms

I get the same errors if I set hugo version to 0.111.3 in the .github/workflows/pages.yaml, so I guess it is due to hugo's version. The weird thing is that it's not the same error about LanguageCode from my first post.

imfing commented 1 year ago

Yeah the languageCode was introduced in v0.112.0

https://gohugo.io/content-management/multilingual/#changes-in-hugo-01120