Possible? First list page showing 9 items, following showing 10 items

I am trying to be extra “kreative” with a list page layout and had the idea to have the homepage of a site showing one single full-width full-content post followed by 8 next posts in two columns (a card-grid-layout thingy). Then, on the following pages I want to just show two columns of posts without the large post. Which basically means I need the homepage show the first 9 posts and all subsequent pages show 10 posts each. I can’t think of any setup for Hugo, that can achieve this. Am I wrong?

My “hacky” thought was, that in the worst case I am ignoring post 10 on the homepage and by checking if I am on a non-homepage then doing the other sub-pages or something along these lines.

I guess in the end, what would enable me to do a weird layout setup like this would be a way to “know” on which list-page I am. If it’s 1 then I do a first 9 $posts range and if it’s 1+n I do an after 9+(n-1)*10 $posts range… That will mess with the pagination, but that is a topic for another day.

Prepend the home page to your page collection, then ignore it.

{{ $p := where site.RegularPages "Type" "post" }}
{{ $p = slice site.Home | append $p }}

{{ range (.Paginate $p).Pages }}
  {{ if not .IsHome }}
    <h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
  {{ end }}
{{ end }}

{{ template "_internal/pagination.html" . }}
7 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.