Need help to exclude tagged posts from header section in Ghost theme Source

Hello Ghost Community!

I need to modify a Ghost theme “Source” to exclude posts tagged “hash-press-release” from appearing in the homepage header section. Ideally, I want to create a dedicated “Press Releases” section in the bottom of the homepage for these excluded posts

I tried to modify header-content.hbs, but all attempts to exclude these tagged posts either result in the posts still appearing or just break the layout of my site.

Any guidance, code examples, or references to the documentation would be greatly appreciated.

For most themes, editing the routes.yaml file would be the answer. That’s true for the /header/ section of Source also. (If you were going after the lower post list, you’d need a different approach.)

See Ghost Themes - Dynamic URLs & Routing for details, but instead of primary_tag, you can also use tag. Here’s an example (partial file - routes and taxonomies not shown):

collections:
  /blog/:
    permalink: /blog/{slug}/
    template: index
    filter: tags:-[cathy-sarisky-portfolio]
    order: published_at desc

  /portfolio/:
    permalink: /portfolio/{slug}/
    template: portfolio-index
    filter: tags:[cathy-sarisky-portfolio]
    order: published_at desc

(After which you’ll upload under ghost> settings > labs)

To make the press releases appear at the bottom of the homepage, add an extra #get request that grabs just them, then loop through them.

1 Like

Thank you a lot! This helped. :kissing_closed_eyes:

1 Like

Just found one more problem, this update successfully removed press releases from the header but links to press releases go to 404 page now.

You need to make sure you’ve got those press releases routed to somewhere. Since you have presumably excluded them from the / route, you need to give them a route of their own. Post your routes.yaml if stuck.

1 Like

I did what you said and it works now, thank you again!

1 Like