Skip to content

Instantly share code, notes, and snippets.

@jbfriedrich
Last active January 5, 2022 05:00
Show Gist options
  • Save jbfriedrich/daae113f213ec27bde1a07b925288246 to your computer and use it in GitHub Desktop.
Save jbfriedrich/daae113f213ec27bde1a07b925288246 to your computer and use it in GitHub Desktop.
Hugo Template - List All Regular Pages
{{/* This can be used to loop through all regular pages on the whole site. */}}
{{ $pages := .Paginate ( where .Site.RegularPages "Type" "in" site.Params.mainSections ) }}
{{ range $pages.Pages }}
<article class="post type-{{ .Section }}">
{{ if eq .Section "posts" }}
<a class="post-full-link" href="{{ .RelPermalink }}">
<h4 class="post-date">{{ .Page.Date.Format "2 Jan 2006, 15:04 MST" }}</h4>
<h1 class="post-title">{{ .Title }}</h1>
<div class="post-summary">
{{ .Page.Summary }}
</div>
{{ if .Truncated }}<h5 class="post-readmore">Read more »</h5>{{ end }}
</a>
{{ else if eq .Section "status" }}
<a class="post-full-link" href="{{ .RelPermalink }}">
<h4 class="post-date">{{ .Page.Date.Format "2 Jan 2006, 15:04 MST" }}</h4>
<div class="post-summary">
{{ .Page.Summary }}
</div>
<h5 class="post-readmore">Read more »</h5>
</a>
{{ end }}
</article>
{{ end }}
{{/* This can be used to loop through all regular pages within a section. */}}
{{ $paginator := .Paginate .RegularPages }}
{{ range $paginator.Pages }}
<p>{{ .Page.Title }}</p>
{{ end }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment