HUGO

Random error ".GetPage is not a method but has arguments"

Hi! I’m randomly having this strange error (for the first time since 2 years using Hugo) which doesn’t explain itself.

Log excerpt:

hugo v0.86.0-41C6C52E+extended linux/amd64 BuildDate=2021-07-21T09:53:14Z VendorInfo=gohugoio
(...) error calling partialCached: "/opt/build/repo/layouts/partials/seo/elements/authorID.html:1:9": execute of template failed: template: partials/seo/elements/authorID.html:1:9: executing "partials/seo/elements/authorID.html" at <.GetPage>: GetPage is not a method but has arguments

The authorID.html partial:

{{- with .GetPage "/biografia/" -}}
  {{- return delimit (slice .Permalink "#id") "" -}}
{{- end -}}

That partial is always called via partialCached (without variants), in a sequence of nested partials that build JSON-LD for my pages. I don’t know if it has to do with caching, because it’s an intermitent error: that partial usually works.

First it happened at Netlify build; I retried the deploy, same error. I just commited something unrelated (npm update) and error gone. Soon after, it happened locally at my machine, but again without any apparent reason.

Please, any help? I don’t know how to figure out the reason of that error… Thank you in advance!

I’m guessing that you sometimes call partialCached with something other than a Page, and the usually works comes from the cache (you are usually lucky with the first invocation).

You can test out that theory by using the regular partial func.

@bep you’re right! I’ve tried using partial before posting here, but didn’t note a call to that partial using $ as parameter (to catch Page from calling partial). But $ in fact resolved to Page.Params, not Page, and so the error.

Thank you, and sorry for the silly error and topic. :smile:

1 Like

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