.Site.GetPage breaking changes with 0.45

Just updated to 0.45 on my local machine and now some of the code I’ve used fails to build. Both are related to the way I’ve use .Site.GetPage.

{{ range $key, $taxonomy := .Site.Taxonomies.state }}
  {{ $term := $.Site.GetPage "taxonomy" "state" $key }}
    {{ $term.Permalink }}
    {{ $term.Title }}
    {{ range $taxonomy.Pages }}
        {{ .RelPermalink}}
        {{ .Permalink}}">
        {{ .LinkTitle }} 
    {{ end }}
{{ end }}

It throws the following error:
<$.Site.GetPage>: error calling GetPage: too many arguments to .Site.GetPage:

This code is also based on the of the code snippets in the Documentation. I’ll try to find the exact bit.

I have a similar issue with a shortcode I’ve made that looks like this:
{{ with $.Site.GetPage "page" "concursos" (printf "%s.md" (.Get 0)) }}

Throws the same error “too many arguments”.

I see there was some changes in 0.45 that affects this.

.Site.GetPage with more than 2 arguments will not work anymore. This means that {{ .Site.GetPage "page" "blog" "my-post.md" }} will fail. {{ .Site.GetPage "page" "blog/my-post.md" }} will work, but we recommend you use the simpler {{ .Site.GetPage "/blog/my-post.md" }}

1 Like

I’ve read that already, and refactoring the shortcode with that format works, however, the first snippet still prints an error.

Changing the first snippet into:

{{ range $key, $taxonomy := .Site.Taxonomies.state }}
  {{ $term := $.Site.GetPage "state" $key }}

Actually causes a panic exit.

Please post the panic output.

CC/ @bep this seems related to GitHub issue #4989

The above isn’t correct. It should be something like this:

{{ term := .Site.GetPage (printf “/state/%s” $key) }}

2 Likes

Takk for hjelpen. :slight_smile:

The snippet bep posted does fix the issue. However, I suspect there are some snippets in the docs that will contain these breaking changes.

Why do you suspect that? I did a search for all GetPage strings and I think I got them all. Do you have any examples that I missed?

1 Like

If the documentation is already updated with the relevant changes, then it should be fine. Good job!