gohugo-theme-ananke icon indicating copy to clipboard operation
gohugo-theme-ananke copied to clipboard

Fix rendering breakage introduced in #665

Open ramiro opened this issue 9 months ago • 7 comments

A bare bones setup of two pages and two posts gets broken because of a template change missed in #665

Fatal error message in readable form:

ERROR render:
failed to render pages:
render of "home" failed: "themes/ananke/layouts/index.html:48:23":
execute of template failed:
template:
index.html:48:23:
executing "main" at <.Site.GetPage>: can't evaluate field Site in type string

Steps to reproduce:

hugo new site quickstart
cd quickstart
git init
git submodule add https://github.com/theNewDynamic/gohugo-theme-ananke.git themes/ananke
echo "theme = 'ananke'" >> hugo.toml
echo -e "+++\ntitle='Home'\n+++\n\nMain page" > content/_index.md
echo Foo. > content/page1.md
echo Bar. > content/page2.md
mkdir -p content/post
echo "First post." > content/post/post1.md
echo "Second post." > content/post/post2.md
hugo server

Output:

Watching for changes in quickstart/{archetypes,assets,content,data,i18n,layouts,static,themes}
Watching for config changes in quickstart/hugo.toml, quickstart/themes/ananke/config.yaml
Start building sites …
hugo v0.125.3-474c4c02212cf97712c6fbf4159c68822ea6e078+extended darwin/amd64 BuildDate=2024-04-22T17:18:35Z VendorInfo=brew

Built in 67 ms
Error: error building site: render: failed to render pages: render of "home" failed: ".../quickstart/themes/ananke/layouts/index.html:48:23": execute of template failed: template: index.html:48:23: executing "main" at <.Site.GetPage>: can't evaluate field Site in type string

ramiro avatar Apr 25 '24 10:04 ramiro

Deploy Preview for gohugo-ananke-theme-demo canceled.

Name Link
Latest commit bbd9d80f8d8aa0052ecca099ec0c750ec11c950d
Latest deploy log https://app.netlify.com/sites/gohugo-ananke-theme-demo/deploys/662a2d2d193b5c00082b9a68

netlify[bot] avatar Apr 25 '24 10:04 netlify[bot]

If you run a preview of the example site, you will encounter the same error.

deining avatar Apr 26 '24 20:04 deining

We just had the first report of this on the Hugo forum. Hugo's quick start guide currently instructs users to install Ananke, so they're going to run into a dead end.

I haven't reviewed this PR or #665, but in the short term I'd be inclined to simply revert f34c219436ab1c3b116f8706a521d40c4b8693b9.

jmooring avatar Apr 28 '24 20:04 jmooring

I can confirm, that this (very simple) PR fixed the issue. In my case, when I had 4 and more pages in a section, the generation was failing (as it attempts to do some "see all pages" etc.). This PR fixed the issue.

vlcinsky avatar Apr 30 '24 07:04 vlcinsky

I can testify that this issue breaks the website rendering.

In the meantime, is there a way to statically set the version of the theme I use in order to fix the build?

oupala avatar Apr 30 '24 14:04 oupala

@oupala If you've added the theme to your Hugo project as a git submodule, you can:

cd themes/ananke/
git checkout 0d06863

jmooring avatar Apr 30 '24 15:04 jmooring

@oupala If you've added the theme to your Hugo project as a git submodule, you can:

I don't think I have added the theme as a submodule

I'm using the following method to add the theme:

hugo mod get -u github.com/theNewDynamic/gohugo-theme-ananke

with a go.sum and a go.mod file

I think the go.mod file is referencing a specific version:

require github.com/theNewDynamic/gohugo-theme-ananke v0.0.0-20231122160523-91df000ca827 // indirect

oupala avatar Apr 30 '24 15:04 oupala

@oupala

hugo mod get -u github.com/theNewDynamic/gohugo-theme-ananke@0d06863

Your go.mod file should then look like:

require github.com/theNewDynamic/gohugo-theme-ananke v0.0.0-20240418152324-0d068637ccd8 // indirect

jmooring avatar Apr 30 '24 16:04 jmooring

@jmooring It looks like this workaround does not work:

$ hugo mod get -u $THEME_URL
hugo: collected modules in 1467 ms
go: downloading github.com/theNewDynamic/gohugo-theme-ananke v0.0.0-20240418152630-f34c219436ab
go: upgraded github.com/theNewDynamic/gohugo-theme-ananke v0.0.0-20240418152324-0d068637ccd8 => v0.0.0-20240418152630-f34c219436ab

and I still get the same error in the build:

Error: error building site: render: failed to render pages: render of "home" failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/the!new!dynamic/[email protected]/layouts/index.html:48:23": execute of template failed: template: index.html:48:23: executing "main" at <.Site.GetPage>: can't evaluate field Site in type string

oupala avatar May 02 '24 09:05 oupala

@oupala please don't hijack this issue's comments for personalized support for deploying Hugo and its themes. All the other subscribers genuinely interested in the actual issue receive a notification with each post

ramiro avatar May 02 '24 09:05 ramiro

I ran into the same issue (sorry oupala not the same one you have) and independently found the same solution. This PR fixed the issue and is an easy win.

thesamrooney avatar May 02 '24 18:05 thesamrooney

Sorry about the delay. And thanks for the fix.

regisphilibert avatar May 03 '24 17:05 regisphilibert