Skip to content

Instantly share code, notes, and snippets.

@budparr
Last active May 6, 2021 14:12
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save budparr/c019eecce25ca4b8809fa91f16bee3ec to your computer and use it in GitHub Desktop.
Save budparr/c019eecce25ca4b8809fa91f16bee3ec to your computer and use it in GitHub Desktop.
multiple where statements Remember that Hugo uses parameters in the range statement from the inside out. Order matters.
{{ range first 3 (where (where .Site.Pages.ByDate.Reverse "Section" "posts") ".Title" "!=" .Title) }}
<!-- latest posts -->
{{ end }}
{{ range sort (where .Site.Pages "Section" "contributors") "Params.last_name" }}
{{ $yoyo := .Title }}
{{ if .Params.last_name }}
<h2>title: {{ $yoyo }} | last: {{ .Data.Prev }}</h2>
{{ end }}
{{ end }}
https://discuss.gohugo.io/t/confusion-regarding-template-conditionals-and-strings/2042/5
<div class="posticon">
{{ if (not (isset .Params "mdrposticon")) | or (eq .Params.mdrposticon "") }}
<img src="/icons/default.png" />
{{ else }}
<img src="{{.Params.mdrposticon }}" />
{{ end }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment