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

Fix rendering breakage introduced in #665 #685

Merged

Conversation

ramiro
Copy link
Contributor

@ramiro ramiro commented Apr 25, 2024

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

A bare bones setup of two pages and two posts gets broken because of a
template change missed in theNewDynamic#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:

```shell
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
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
```
Copy link

netlify bot commented Apr 25, 2024

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

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

@ramiro ramiro changed the title Fix render breakage introduced in #665 Fix rendering breakage introduced in #665 Apr 25, 2024
@deining
Copy link
Contributor

deining commented Apr 26, 2024

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

@ramiro ramiro mentioned this pull request Apr 27, 2024
@jmooring
Copy link
Contributor

jmooring commented Apr 28, 2024

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 f34c219.

@vlcinsky
Copy link

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.

@oupala
Copy link

oupala commented Apr 30, 2024

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?

@jmooring
Copy link
Contributor

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

cd themes/ananke/
git checkout 0d06863

@oupala
Copy link

oupala commented Apr 30, 2024

@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

@jmooring
Copy link
Contributor

jmooring commented Apr 30, 2024

@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

@oupala
Copy link

oupala commented May 2, 2024

@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/gohugo-theme-ananke@v0.0.0-20240418152630-f34c219436ab/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
Copy link
Contributor Author

ramiro commented May 2, 2024

@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

@thesamrooney
Copy link

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.

@regisphilibert regisphilibert merged commit 33fbda0 into theNewDynamic:master May 3, 2024
4 checks passed
@regisphilibert
Copy link
Member

Sorry about the delay. And thanks for the fix.

regisphilibert pushed a commit that referenced this pull request May 3, 2024
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:

```shell
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
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
```
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

Successfully merging this pull request may close these issues.

None yet

7 participants