Filter newsletters from homepage

Hey folks, I am using the Source theme and trying to keep my newsletters (with tag ‘Newsletter’) from showing up on my homepage and from my blog posts and RSS. I had this working at one point, with Casper, but I can’t for the life of me remember how I got it working with my routes.yaml. I’ve gone through the tutorial, and the posts in the forum, but nothing I’ve tried works.

Any guidance would be appreciated.

1 Like

Okay, I think I have the RSS part figured out just by filtering out the tag from the blog collection and using /blog/rss as the RSS feed.


collections:
  /blog/:
    permalink: /{slug}/
    template: index
    filter: tag:-[Newsletter]
  
  /newsletter/:
    permalink: /{slug}/
    template: index
    filter: tag:[Newsletter]

Still trying to work out the homepage, though.

Yes, using the documented methods, the source template doesn’t filter out the tags on the home page. There must be a way.

Source is making #get requests on the homepage, and those requests don’t know about your routing file. The workaround is a pretty easy tweak to the theme files. (Doable for self-hosters and anyone with a plan that allows uploading a theme, which is pretty much everyone except Basic users on Ghost Pro.)

I see. I was under the impression that the filtering tutorial and documentation would work across all Ghost authored themes. It should be noted in the tutorials which themes the suggested techniques apply.

Good point! Paging @RyanF ! In addition to Source, I think Headline is also impacted.

1 Like

Thanks Cathy. I did try tweaking the theme files but couldn’t get the result that I wanted. I went back to using the Ubud theme, which makes it easier to control what appears on the home page.

Hi, I’m also struggling with how to filter my home page posts in Source theme. My tag filter works on the #get request to filter the “latest” list in post-list.hbs, but I haven’t been able to get a filter working for the #foreach loop in header-content.hbs for the Magazine layout. I’ve tried:
{{#foreach posts filter=“tag:breadandstories” limit=“7” }}
Thanks in advance for any help you can offer.

You need a routes.yaml to say which posts are in the / collection. Any time you see foreach not inside get, that’s what’s going on. :slight_smile:

1 Like

Thanks, Cathy! That did the trick.

1 Like