404 for posts that do not have the tag my channel filters on

Hi everyone! :wave:

The issue at hand: When I don’t give my posts (also) the tag I’m filtering my channel (=homepage) on, those posts are not found on the front end (404).

The posts do render under a tag collection though (example) but if you click the post is renders a 404.

Would love you forever (not forever maybe, but at least for quite some time) if you help me solve this one. :wink:

The top part of my routes.yaml:

routes:
  /:
    controller: channel
    template: index
    filter: tag:nieuws
  /aanbod/: aanbod
  
collections:
  /leden/architecten/:
    permalink: /leden/{slug}/
    template: tag-leden-categorie
    filter: tag:categorie-architecten
    data: tag.categorie-architecten
  /leden/installateurs-aannemers/:
    permalink: /leden/{slug}/
    template: tag-leden-categorie
    filter: tag:categorie-installateurs-aannemers
    data: tag.categorie-installateurs-aannemers
  /leden/kennisinstellingen/:
    permalink: /leden/{slug}/
    template: tag-leden-categorie
    filter: tag:categorie-kennisinstellingen
    data: tag.categorie-kennisinstellingen

You’ve misunderstood how collections work. Every post must be part of a collection, or it won’t get routed. The collection specifies the URL. Posts get put into the first collection that they match, based on your filters (if any).

So you need to add this to your collections, at the BOTTOM, so that it catches things that aren’t already routed.

  /other/:
    permalink: /other/{slug}
    template: index
    

You can pick a different path for the collection, and of course a different slug style for posts in it, including just /{slug}. Don’t put the path as /: in your specific case, because you’ve already got a channel route there.

1 Like

I indeed misunderstood how they worked! (even after using them for years… :roll_eyes:)

You made my day! Thanks!

1 Like