Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
billux opened this issue Sep 19, 2023 · 3 comments
Closed

Comments

@billux
Copy link

billux commented Sep 19, 2023

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/[email protected]/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
@billux billux changed the title Got template error folowing the Getting Started Got a template error when following the Getting Started instructions Sep 19, 2023
@imfing
Copy link
Owner

imfing commented Sep 19, 2023

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

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

@billux
Copy link
Author

billux commented Sep 19, 2023

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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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
Copy link
Owner

imfing commented Sep 19, 2023

Yeah the languageCode was introduced in v0.112.0

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

@imfing imfing closed this as completed Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants