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.

Thank you a lot! This helped. :kissing_closed_eyes:

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.

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

Is this possible using code injection too?

Routing and code injection are separate. But I think your real question is “can I do this with the starter plan”, right? If so, the answer is yes. You can upload a routes.yaml file with the starter plan. :)

Note that themes with fancy homepages may ignore routing on the homepage. (You can still use a routes.yaml to make something like /writing/ and /blog/, however.)

Probably great advise [as usual] but I would not even know what routing is… :grimacing:

Read the link in my first post on this thread. :slight_smile:

I did and I don’t understand it. I will leave it for now and dream of a theme that looks like source with the homepage functionality of headline :D