I am trying to render a list of posts on my homepage showing only a summary. I would like to preserve the formatting of the summary and any links. However, all HTML is stripped from the summary. Code is below.
{{ define "main" }}
{{ $pages := where site.RegularPages "Type" "posts" }}
{{ range (.Paginate $pages).Pages }}
<article class="post h-entry">
<div class="title p-name">
<h1>
{{ .Title }}
</h1>
</div>
<div class="content p-summary">
{{ .Summary | safeHTML }}
{{ if .Truncated }}
<a href="{{ .RelPermalink }}">Read more</a>
{{ end }}
</div>
{{ partial "articleInfo.html" . }}
</article>
{{ end }}
{{ partial "pagination.html" . }}
{{ end }}
If I replace .Summary
with .Content
the full HTML is rendered even without the | safeHTML
. I have also tried .Summary | markdownify
but there is no difference. I think that I am misunderstanding the usage of safeHTML or possibly the scope of .Summary. Any help resolving this issue is appreciate.