Using routes to have a collection and still show on homepage

I am getting a little confused with the routes.yaml

I have the following setup at the moment:

  /:
    permalink: /{primary_tag}/{slug}/
    template: index
    filter: tag:-[guide,patch-notes,film-news,news]

  /guide/: 
    permalink: /guide/{slug}/
    template: guide
    filter: tag:guide
  
  /patch-notes/: 
    permalink: /patch-notes/{slug}/
    template: patch-notes
    filter: tag:patch-notes
  
  /film-news/: 
    permalink: /film-news/{slug}/
    template: film-news
    filter: tag:film-news

  /news/: 
    permalink: /news/{slug}/
    template: news
    filter: tag:news

Now this works so that all 4 of these tags have their own page, and do not show on the homepage.

The issue is that I still want the film-news and news tag to show on the homepage but if I remove the tags from the filter, the collection page still exists but shows no posts at all.

I have tried everything to get this to work but have come to the forums to see if anyone else has managed to fix this issue? or if it’s a bug?

1 Like

Collections take all posts that match them in the order they occur. So posts go to the first one that matches them.

You may want to look at setting up a channel instead of a collection.

4 Likes

Thanks Cathy, I’m annoyed at myself for not thinking of using the channel instead of collection.

Just changed it all now and it worked straight away, lol.

1 Like

Hey, would you be able to share how your routes look now please. I’m trying to customize my homepage too, but don’t know how to use channel routing :(

Of course mate, this is my current routes.yaml:

routes:
  /signup/: members/signup
  /signin/: members/signin
  /account/: members/account
  /offline/: offline
  /sitemap/:
    template: sitemap
    content_type: text/xml
  /news/rss/:
    template: news/rss
    content_type: text/xml

  /film-news/: 
    controller: channel
    template: film-news
    filter: tag:film-news
  
  /news/: 
    controller: channel
    template: news
    filter: tag:-[guide,patch-notes,film-news]

  /patch-notes/: 
    controller: channel
    template: patch-notes
    filter: tag:patch-notes

  /game-guides/: 
    controller: channel
    template: guide
    filter: tag:game-guides

collections:
  /:
    permalink: /{primary_tag}/{slug}/
    template: index
3 Likes