Hello, I use:
{{ with site.RegularPages.Related . | first 5 }}
<p>Related content:</p>
<ul>
{{ range . }}
<li><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
{{ end }}
</ul>
{{ end }}
successfully without errors in my page.html template.
So that I could use the same code in only some pages, I created a shortcode and put the same code in it and get errors:
execute of template failed: template: _shortcodes/related-pages-shortcode.html:1:13: executing “_shortcodes/related-pages-shortcode.html” at <site.RegularPages.Related>: error calling Related: invalid argument type *hugolib.ShortcodeWithPage
I have spent hours and hours trying to debug this. I have asked AI for help, it can often be very helpful but in this case makes suggested changes, which still cause errors, and then makes more changes which still causes errors, over and over.
Any help on this would be much appreciated. Thanks ahead of time for any assistance.