Study Guide: List Related Content
How to create a list of files from a directory in Hugo.
{{ $posts := where (where .Site.RegularPages ".Params.topics" "intersect" .Params.topics) "Permalink" "!=" .Permalink -}}
{{- with $posts -}}
<div class="no-print"><!-- Original code from https://novelist.xyz/tech/related-posts-in-hugo/ -->
<h4>Related Content</h4>
<ul>
{{ range first 8 . -}}
<li class="relatedPost"> <a href="{{ .RelPermalink }}">{{ .Title | title }}</a></li>
{{- end }}
</ul>
</div>
{{- end }}
Related Content
Source: //study/hugo/hugo-list-related-content/
