Last active
January 5, 2022 05:00
-
-
Save jbfriedrich/daae113f213ec27bde1a07b925288246 to your computer and use it in GitHub Desktop.
Hugo Template - List All Regular Pages
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
{{/* 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