Hide specific posts from homepage in Ghost

Four different styles of blank gift tags.
You get a tag, and you get a tag, and you get a tag.

I recently became a dad and plan to occasionally write about my experience. That said, since my blog is primarily about technology, I don't want those posts surfacing on the homepage, because they're not written for my target audience.

The first step is to group all of the Parenting posts together. Since I tag all my posts anyway, it made sense to create a Parenting tag. This then also gives me a tag archive of those posts, which I will link to in the main menu.

Next I'll create a new collection. You can do this by defining a slug for this collection in your routes.yaml file. Head on over to Settings > Labs > Beta Features > Routes, and click on Download current routes.yaml.

routes:

collections:
  /:
    permalink: /{year}/{month}/{slug}/
    template: index

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

Yours likely won't look exactly like this, because I included the month and year in my permalinks, but notice how I only have one collection called /. We're going to add another collection called parenting, but you can all it whatever you want.

routes:

collections:
  /parenting/:
    permalink: /{year}/{month}/{slug}/
    template: index
  /:
    permalink: /{year}/{month}/{slug}/
    template: index

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

It's important that parenting is above /, because it's a more specific.

Now we choose which posts we want in this collection, and as you might have guessed, we want all posts tagged as Parenting in there. We'll add a filter for that.

routes:

collections:
  /parenting/:
    permalink: /{year}/{month}/{slug}/
    template: index
    filter: tag:parenting
  /:
    permalink: /{year}/{month}/{slug}/
    template: index

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

This is where the magic happens, because out of the box, posts can only be in one collection, and when those posts get funneled into the parenting collection, they'll no longer appear in /, effectively removing them from the homepage.

Once you have your YAML file the way you want, you can click the Upload routes YAML button to apply those changes.

Featured image by Angèle Kamp.