Render issue when pasting fourth post

If I copy a post from content/posts, and then paste it into the same directory, it appears on the site as normal. But if I paste it three times or more, it gives this error:

 render: failed to render pages: render of "home" failed: e[1;36m"/Users/testuser/Desktop/hugo/themes/ananke/layouts/index.html:48:23"e[0m: execute of template failed at <.Site.GetPage>: can’t evaluate field Site in type string 
/Users/testuser/Desktop/hugo/themes/ananke/layouts/index.html:48:23:

          {{/* As above, Use $section_name to get the section title, and URL. Use "with" to only show it if it exists */}}
          {{ with .Site.GetPage "section" $section_name }}
            <a href="{{ .RelPermalink }}" class="link db f6 pa2 br3 bg-mid-gray white dim w4 tc">{{ i18n "allTitle" . }}</a>
          {{ end }}

hugo v0.125.4+extended darwin/amd64 BuildDate=2024-04-25T13:27:26Z VendorInfo=brew

However, if I delete the third post that I pasted, the error goes away, and the other pasted posts appear as expected with no errors:

Are you cutting and pasting while hugo server is running? It yes, what happens if you stop the server and restart?

@jmooring , Yes I’ve tried when server is running and not running. The server won’t even start if I add/paste the third post and then run “hugo server -D”. It gives error:

~/Desktop/hugo$ hugo server -D
Watching for changes in /Users/testuser/Desktop/hugo/{archetypes,assets,content,data,i18n,layouts,static,themes}
Watching for config changes in /Users/testuser/Desktop/hugo/hugo.toml, /Users/testuser/Desktop/hugo/themes/ananke/config.yaml
Start building sites … 
hugo v0.125.4+extended darwin/amd64 BuildDate=2024-04-25T13:27:26Z VendorInfo=brew

Built in 113 ms
Error: error building site: render: failed to render pages: render of "home" failed: "/Users/testuser/Desktop/hugo/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

I am unable to reproduce the problem. Can you share your repository?

@jmooring , I’ve just uploaded it to: GitHub - airely1/temprepo

When the file “my-first-post copy 3.md” is deleted from content/posts, the site appears as normal. But gives the error when it exists.

Thanks for your help.

Sorry, I was testing with an older version of the Ananke theme.

Someone broke the Ananke theme last week:
https://github.com/theNewDynamic/gohugo-theme-ananke/pull/665

There’s an open PR to fix it:
https://github.com/theNewDynamic/gohugo-theme-ananke/pull/685

Did you install the theme as a Git submodule?

@jmooring Ah right. It’s my first time running a Hugo theme and I didn’t think to check the Issues tab in Github. Will do in future.

Adding $ before the first period in /themes/ananke/layouts/index.html fixed the issue.

Thanks for your help!

Yes I ran:
git submodule add GitHub - theNewDynamic/gohugo-theme-ananke: Ananke: A theme for Hugo Sites themes/ananke

That may not be the only problem with the changes made in https://github.com/theNewDynamic/gohugo-theme-ananke/pull/665.

If I were you, I would:

cd themes/ananke/
git checkout 0d06863

And don’t make any more changes to the files in themes/. Instead, override them by creating a copy in the same path relative to your site root (e.g., override themes/ananke/layouts/foo.html by creating layouts/foo.html).

Tracking the upstream problem here:
https://github.com/gohugoio/hugoDocs/issues/2548

@jmooring thanks for the advice.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.