Anchor links after <!--more-->

This one is kind of easy, but tricky.

In “summary.html”

{{ if .Truncated }}
    {{ .Summary |  safeHTML }}
    <a href="{{ .Permalink }}#{{ .Title | urlize }}" class="read_more">Read more...</a>
    {{ else }}
    {{ .Content}}	
{{ end }}

In “single.html”

<article>
   <a name="{{ .Title | urlize }}"></a>
   {{ . Title }}
   {{ .Content }}
...

That’s it. When you do your <!--more--> guess what’s going to happen? You are going to get the title’s ID as an anchor text before your Title in the single version of the page.

Boom.

2 Likes

mostly you can make it easier

substitute"{{ .Title | urlize }}" with a fixed string like"content" in both templates

2 Likes