<.Site.GetPage>: can't evaluate field Site in type string


My problem is very similar to this one

In the _index.md from my homepage I define:
category_sub1_urls = ["/gaming-pc/budget-builds/best-gaming-pc-under-300","gaming-pc/budget-builds/500-gaming-pc"]

In my index.html I tried:
{{ range $element := .Params.category_sub1_urls }}
<li>{{ printf "%s" $element }}</li>
{{ with $.GetPage "$element" }}
<li><a href="{{ .Permalink }}">{{ .Title }}</a></li>
{{ end }}
{{ end }}

like mentioned in the other solution - but it’s blank
{{ with .Site.GetPage "$element" }}
or with
{{ with .Site.GetPage (printf "%s" $element) }}
I get the error above

The elements are found - and shown on screen - but the .site.get.page doesn’t seem to function within the range.

Source here - problem is in the _index.md from the homepage


"$element" is a string with the value "$element" ; $element is a variable containing a string, which is presumably what you want.

Have you tried {{ with $.Site.GetPage $element }} ?

1 Like

The one combination I did not try - and it works. Only used the “$element” because it was in the example like that - before was using print “%s” because that was the way it worked with a single variable
Really appreciate your help!

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