I need a strategy for filtering out posts from home page list

Hi, everyone. I’m looking for a strategy for filtering out posts from my home page list. I converted a site from Drupal over to HUGO and used the “promote to front page” flag to keep some posts from appearing on the front of my site.

I was thinking that I could create some type of status flag and for some posts would have that set to “not promoted” or something. I’m not sure I understand what the best approach would be for doing this.

I’ve tried creating a taxonomy using this in frontmatter:

promo = ["no"]

I’m finding it hard to figure out how to properly filter them out from my index listing. Is there a way to use a where statement that generates a list while filtering out results matching a term from a taxonomy? Or maybe someone has had a similar use case and has a better approach that they can suggest?


See the list of functions on this page.

Where is what you want. There are examples on that page.

Thanks. That is indeed what I was staring at, but what I’m trying doesn’t seem to be right.

In config.toml I now have this:

  tag = "tags"
  status = "status"

In one post that I want to hide I include this for instance:

title = "Nulo"
description = ""
tags = ["music"]
date = "2015-03-22"
status = "nopromo"
slug = "nulo"

Finally, in my theme’s root index.html I have this which produces an empty list:

{{ range first 5 (where .Site.Recent "Params.status" "!=" "nopromo") }}
{{ .Render "list-node"}}
{{ end }}

It seems right if I’m understanding the docs, but I’m sure I’m missing something.

I would use params for this, which can take any types, like the bool showOnFrontpage.

Thanks, guys. I think I got what I need. Am just checking for {{ if not (isset .Params “nopromo” ) }} and that’s working fine although this is how I did it:

{{ range first 10 .Site.Recent }}
  {{ if not (isset .Params "nopromo" ) }}
    {{ .Render "list-node"}}
  {{ end }}
{{ end }}

It’s not ideal, because what I wanted was to show latest 10 posts, but I end up just subtracting any of those posts that have the nopromo param.

I think you should read the above posts again, esp. the ones about where.