ahmet
1
Imagine I have the following content doc:
sentence1 hello world. <!--more--> sentence2 hello world.
another paragraph..
As you’d see, the summary here is only the sentence1[…].
However, when I try to use {{.Summary}}
and add a “Read More →” like this:
{{ .Summary}}
<a href="{{ .RelPermalink }}">
<b>Read More →</b>
</a>
The summary is surrounded in a paragraph (<p>
). Therefore the “Read More →” link is pushed to a separate paragraph like this when HTML is rendered:
sentence1 hello world.
Read More →
I’m coming from another CMS (Pelican) where this was not the case.
Is there a way to prevent this?
maiki
2
You can set variables and and build the summary manually. I wouldn’t, I don’t think the read more button belongs in that paragraph. 
zwbetz
3
See this previous thread for some ideas: Inconsistent behavior with .Summary tag
1 Like
ahmet
5
I’ve noticed there’s no easy way around this, so I hacked this:
Pretty much every {{.Summary}}
will end with </p>
regardless of having a <!--more-->
separator or not.
Therefore I will (1) delete the final </p>
, insert my Read More
link, add </p>
again to keep the paragraph intact. It looks like this:
{{ replaceRE "(</p>)?$" "" .Summary | safeHTML }}
<a href="{{ .RelPermalink }}">
Read more →
</a>
{{ printf "</p>" | safeHTML }}