Hello, I’m having some difficulty figuring out how to display a range section when my section uses canonized urls… What I mean is, Hugo outputs my posts like this: https://www.screencast.com/t/pvfCxf49kIhD
Which I think is why my code isn’t catching the posts, it only catches the post index. This is my current code:
<h1>Featured</h1>
{{ range where (where .RegularPages "Section" "post" ) ".Params.featured" "!=" true }}
{{ partial "content.header.html" . }}
<p>{{ .Summary }}</p>
{{ if .Truncated }}
<p><a href="{{ .RelPermalink }}">Read On →</a></p>
{{ end }}
{{ end }}
<h1>Posts</h1>
{{ range where .RegularPages "Section" "post" }}
{{ partial "content.header.html" . }}
<p>{{ .Summary }}</p>
{{ if .Truncated }}
<p><a href="{{ .RelPermalink }}">Read On →</a></p>
{{ end }}
{{ end }}
Any help is appreciated.
Bade something similar recently, hope it helps.
{{ $helpdesk := . }}
{{ range $helpdesk.Pages.ByWeight }}
{{ $section := . }}
{{ $child_pages := union .Sections .Pages }}
<h2 class="text-3xl leading-6 font-semibold text-gray-800 block mb-6">{{ $section.Title }}</h2>
<div class="grid grid-cols-3 gap-12 pb-12">
{{ range $section.Pages.ByWeight }}
<a href="{{ .RelPermalink }}" class="bg-white rounded-md shadow-md hover:shadow-xl py-8 px-6 transition-all duration-150 ease-linear delay-75 transform hover:-translate-y-1">
<h3 class="text-xl text-gray-800 mb-4 font-semibold text-center">
{{ .Title }}
</h3>
{{ with .Params.description}}
<div class="text-gray-700 text-center text-sm">
{{ . }}
</div>
{{ end }}
<div class="text-indigo-500 text-sm text-center font-semibold pt-4">
{{ len $child_pages }} {{ T "articles"}}
</div>
</a>
{{ end }}
</div>
{{ end }}
And when you only want to list the pages of a section
{{ range .Pages.ByWeight }}
<a href="{{.RelPermalink}}" class="text-lg text-indigo-500 mb-4 font-semibold ">
{{ .Title }}
</a>
{{ end }}
