Last active
January 29, 2020 11:27
-
-
Save celestehorgan/41f09b89aacfed430c095f194c5df58d to your computer and use it in GitHub Desktop.
Hugo - Iterate over section and subsections
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ $allSections := site.Sections }} <!-- "blog" and "docs" --> | |
{{ $docsSections := where $allSections "Section" "docs" }} <!-- "getting-started" and "deployment" --> | |
{{ $thisUrl := .RelPermalink }} <!-- the URL of the current page --> | |
<h2>Docs</h2> | |
{{ range $docsSections }} | |
<ul> | |
<li> | |
{{ .Title }} | |
{{ range .RegularPages }} | |
<ul> | |
<li> | |
{{ .Title }} | |
</li> | |
</ul> | |
{{ end }} | |
</li> | |
{{ range .Sections }} | |
<li> {{ .CurrentSection.Title }} | |
<ul> | |
{{ range .CurrentSection.RegularPages }} | |
<li> | |
{{ .Page.Title }} | |
</li> | |
{{ end }} | |
</ul> | |
</li> | |
{{ end }} | |
</ul> | |
{{ end }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment