"Read more" links in paginated posts

Hi there! Sorry if this question should be categorised elsewhere, fairly new to all this.

I’m using a theme for my site which by default paginates posts on the front page where you add <!--more--> which is great, but it doesn’t add a “read more” or “continue” or similar link before the fold allowing you to go to the full post - users have to guess that clicking on the heading of the post takes them to the full post.

I added a link to the post’s permalink before the more marker, but then that’s visible in the full post as well. Can someone point me in the right direction of what to put where to support this?

Welcome to the forums! You’ll probably need to load a partial that only loads on paginated pages or whatnot.

The best way to answer a question like this is to check with the theme author, first. Check their issue tracker, if you cloned the theme from an online repo.

The reason that is the best first step is because templating comes down to how the templates interact with each other, and the theme author will have the best idea about where that would go. Also, that is potentially useful feedback for them!

If that is a bust, make sure to include links to the theme in your follow-up, and you site’s source, if that is available. That way we can just clone it and run it locally, to help you figure it out. :slight_smile:

It’s the Tranquilpeak theme. The author has this working on their example page with the theme, but the issue tracker seems to be a bit stale.

Looking at the index.html layout for it, it looks like this…

{{ partial "head.html" . }}
  <body>
    <div id="blog">
      {{ partial "header.html" . }}
      {{ partial "sidebar.html" . }}
      {{ partial "post/header-cover.html" . }}
      <div id="main" data-behavior="{{ .Scratch.Get "sidebarBehavior" }}"
        class="{{ with .Params.coverimage }}hasCover{{ end }}
               {{ if eq .Params.covermeta "out" }}hasCoverMetaOut{{ else }}hasCoverMetaIn{{ end }}
               {{ with .Params.coverCaption }}hasCoverCaption{{ end }}">
        <section class="postShorten-group main-content-wrap">
          {{ $paginator := .Paginate (where .Data.Pages "Type" "post") }}
          {{ range $paginator.Pages }}
            {{ .Render "summary" }}
          {{ end }}
          {{ partial "pagination.html" . }}
        </section>
        {{ partial "footer.html" . }}
      </div>
    </div>
{{ partial "foot.html" . }}

It seems that where it says .Render summary is where you get the bit in the main posts page that shows the text before the more marker. Is there a shortcode or template I can use to refer to the permalink of the page this is a summary of? That way I can add a “read more” link to the index.html template and I’ll be good to go.

Something like this inside the range loop will render the read-more link:

{{- if .Truncated -}}
  <a href='{{ .RelPermalink }}'>&hellip; Read more</a>
{{- end -}}
3 Likes

Thanks very much, that’s EXACTLY what I was after!

A post was split to a new topic: Summary on home page