My code is as follows for my related.html partial, but it seems to be listing an _index.md file. I wonder why that is. {{ if ne .Section “” }}
<div class="related">
{{ $related := .Site.RegularPages.Related .Page | first 16 }}
{{ with $related }}
<h2>Related Articles</h2>
<div class="row">
{{ range . }}
{{ if ne .Section "" }}
<div class="col-md-3 col-sm-6">
<div class="box-image-text shadow" style="height: 280px;">
<div class="top">
<div class="image" style="overflow:hidden">
<a href="{{ .RelPermalink }}">
{{ if isset .Params "banner" }}
<img src="{{ .Site.BaseURL}}img/placeholder.png" data-src="{{ .Params.banner }}" class="img-responsive shadow" alt="{{.Title}}" width="255" height="192" title="{{.Title}}">
{{ else }}
<img src="{{ .Site.BaseURL}}img/placeholder.png" class="img-responsive" alt="{{.Title}}" width="255" height="192" title="{{.Title}}">
{{ end }}
<h4>{{ .Title }}<h4>
</a>
</div>
</div>
</div>
</div>
{{ end }}
{{ end }}
</div>
{{ end }}
</div>
The 5th one should not show up as I’m only doing {{ $related := .Site.RegularPages.Related .Page | first 16 }}
first 16, but filtering out using {{ if ne .Section "" }}
(if page doesn’t belong to a section, don’t show it)
Also, the blank tile is a link to /psychedelics/ main category which as no articles, but only an _index.md with the contents:
+++
title="Psychedelic Research"
description="Explore the best resources in the psychedelic world"
+++
I renamed /content/psychedelics/_index.md to _index.md.backup and still it was showing up. I even deleted that file and a blank link to /psychedelics/ still shows up.
Not sure what’s going on.
Also, just using .RegularPages.Related
gives an error:
Building sites … ERROR 2018/08/31 21:22:28 Error while rendering “page” in “news/authors/hash-borgir/”: template: _default/single.html:76:31: executing “_default/single.html” at <partial "related.htm…>: error calling partial: template: partials/related.html:2:32: executing “partials/related.html” at <.RegularPages.Relate…>: can’t evaluate field RegularPages in type *hugolib.PageOutput
even though all the document says to use “.RegularPages.Related”: Related content | Hugo