I’m trying to make a sidebar partial refering to subsections in my “Test” section. I want to use the .Title
of the subsection, but the reference should go to the first content page inside this subsection. Right now I’ve got the following:
{{ $currentPage := . }}
{{ range .Site.Sections }}
{{ if eq .Title "Test" }}
{{ range .Pages }}
{{ if .IsSection }}
<!-- the following line should refere to the fist subpage instead -->
<a href="{{ .RelPermalink }}">
<h6>{{ .Title }}</h6>
</a>
{{ if .InSection $currentPage }}
{{ range .Pages }}
...
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
.Title
is working as inteded and giving the headline of the subsection. But the .RelPermalink
should be replaced with the RelPermalink of the first content page in this section.
Is there a way to get the permalink of the first element in the collection, like .Pages[0].RelPermalink
?
I’ve tried to use the .Prev method, but I don’t know what to pass as argument. I’ve tried
<a href="{{ with .Pages.Prev . }}{{ .RelPermalink }}{{ end }}" class="d-block">
but it seemed like .Pages.Prev
is nil if I hand a collection as argument.
I’m quite new to Hugo, so thanks for helping!