In the front matter of the posts that you wish to feature, set weight to a negative number (the default is zero). For example, you could consider every post with a weight of -999 to be “featured.”
Then, as you range through the pages, conditionally set a class on a containing <div>:
{{- if eq .Weight -999 -}}
<div class="featured">
{{- else -}}
<div class="not-featured">
{{- end -}}
{{ .Summary }}
</div>
Thanks for your answer. The documentation you quoted would allow me to paginate through my “featured” posts, or my “regular” posts, but what about a pagination containing all of them, starting by the featured ones?
It took me some hard times, but I think I managed to achieve my goal… Finding a source of a lot of my pagination issues in the process.
Using {{ with .Site.GetPage "posts" }} to fetch the posts was a bad idea. It has made the page inherit for the whole /posts/ behavior, such as display /posts/pages/2 for pagination.
I stored the context in a variable instead: $posts := .Site.GetPage "posts".
Here is how I managed to display all my posts, from featured to regular, while being sorted chronologically (from most recent to the most old), with a working pagination.
{{ define "main" }}
<div>
<!-- 1. Get all posts -->
{{ $posts := .Site.GetPage "posts" }}
<!-- 2. Sort them from featured to regular, chronologically -->
{{ $featuredPosts := where $posts.Pages ".Params.featured" true }}
{{ $regularPosts := where $posts.Pages ".Params.featured" false }}
{{ $sortedPosts := union $featuredPosts $regularPosts }}
<!-- 3. Feed the paginator with these sorted posts -->
{{ $paginator := .Paginate $sortedPosts }}
<!-- 4. Loop through the posts -->
{{ range $paginator.Pages }}
{{ partial "post/summary.html" . }}
{{ end }}
<!-- 5. Display the built-in pagination navigation -->
{{ template "_internal/pagination.html" . }}
</div>
{{ end }}
Does that sounds the right solution? Feel free to make any feedback, I’m struggling to master the “GoHugo way of do things”.