With some help from the community, I figured out how to filter the home page of my Micro.blog site to exclude “Micro Posts, “ a category I created for the short posts without a title.

Why? In my case, I want only to show the full articles on my home page. I have a separate page for all my “Micro Posts.” I think this will make my home page more presentable to visitors to the site.

Every theme could differ; mine is based on the default theme.

The trick to filtering the posts by category is to use Hugo’s symdiff function.

Hugo’s symdiff function returns the symmetric difference between two collections. That’s just a fancy way to say: “give me the things that are in either of these collections but not in both.” - @sod

These lines handle the filtering. Replace “Micro Posts” with the name of the category you want to exclude.

{{ $posts := where site.Pages "Type" "post" }}
{{ $hidden_posts := where $posts "Params.categories" "intersect" (slice "Micro Posts") }}
{{ $posts = $posts | symdiff $hidden_posts }}

Next, if we want to continue to use Pagination on the home page, we’ll need to call the Paginate function and pass in the $posts variable created above it.

{{ $paginator := .Paginate $posts }}

Then we pass the $paginator variable into the range function, which will iterate the posts.

{{ $paginator := .Paginate $posts }}

Here is the full code for my /layouts/index.html template.

{{ define "main" }}
<div class="home h-feed">
  <ul class="post-list">
    {{ $posts := where site.Pages "Type" "post" }}
    {{ $hidden_posts := where $posts "Params.categories" "intersect" (slice "Micro Posts") }}
    {{ $posts = $posts | symdiff $hidden_posts }}
    {{ $paginator := .Paginate $posts }}
    {{ range $paginator.Pages }}
    <li class="post-list-item">
      <div class="post-list-item-title"><a href="{{ .Permalink }}">{{ .Title }}</a></div>
      <div class="post-list-item-date">
        <time class="dt-published"datetime="{{ .Date.Format " 2006-01-02 15:04:05 -0700" }}">{{ .Date.Format "Jan 2, 2006"}}</time>
      </div>
      <div class="post-list-item-content">
        <p>{{ .Summary | truncate 300 }} <a href="{{ .Permalink }}" class="continue-link">read more</a></p>
      </div>
    </li>
  </ul>

</div>
<div class="pagination">
  {{ if .IsHome }}
  {{ if .Site.Params.paginate_home }}
  {{ partial "pagination" . }}
  {{ end }}
  {{ else if .Site.Params.paginate_categories }}
  {{ partial "pagination" . }}
  {{ end }}
</div>
{{ end }}