Double tag filter routing

Hi everyone,

I’m currently trying to make a route for my app that would find posts which would have both tags “enfance” and "enfant“

So far I have something like this in my routes.yaml :

collections:
  /blog/enfance/:
    permalink: /blog/enfance/{primary_tag}/
    template: tag
    filter: tag:enfance

I’ve set a post with enfant as the first tag of its tags list and added the enfance tag also. But trying to get blog/enfance/enfant gives me a 404.

Could anyone tell how I could achieve a route that double filters articles on 2 given tags ?

I think filter: tag:enfance+tag:enfant works.

so :

collections:
  /blog/enfance/enfant/:
    permalink: /blog/enfance/enfant/
    template: tag
    filter: tag:enfance+tag:enfant

but it means I would have to hardcode the filters if i want several of them, is there a way to have at least the second filter determined by the slug in the url ?

I don’t know :slight_smile:

Let’s wait for someone who knows.

In your first attempt, you’re missing {slug} from the permalink.

I’ve tried

collections:
  /blog/enfance/:
    permalink: /blog/enfance/{slug}/
    template: tag
    filter: tag:enfance

if it is what you mean but it isn’t working either, it still gives me a 404

also tried

collections:
  /filter/:
    permalink: /filter/{primary_tag}/{secondary_tag}/
    template: tag

and it weirdly redirects me to an article which hasnt any of the two tags i give to the url

Just to confirm: you’re uploading the routes.yaml in the dashboard under the labs section, right? Not as part of the theme?

And the slug there is the post (not page) slug? That post is published and has the tag, not starting with #?

I’m running ghost locally and editing the routes.yaml directly, restarting ghost everytime, tags arent starting with “#”

Which directory is routes.yaml in?

in content/settings, but I’m not sure the problem comes from my file editing, changes seems to be applied correctly, I think it’s some kind of syntax issue that I cannot put my finger on

I’m pretty sure Ghost doesn’t recognize {secondary_tag}. But {primary_tag} should be usable.

Can you post the entire routes file?

So I’m trying this:

routes:

collections:
  /blog/enfance/:
    permalink: /blog/enfance/{primary_tag}/{slug}/
    template: tag
    filter: tag:enfance
  
taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

Oh, hang on. This puts posts at /blog/enfance/-yourprimarytag-/-yourpostslug-/ but the index is at /blog/enfance/

Are you looking for the index to be at /blog/enfance/-yourprimarytag-/ ? I don’t think there’s a way to do that without specifying each tag combination.

my complete routes.yaml :

routes:
  /: trust_yourself
  /articles/: articles
  /contact/: contact
  /parents-drh-entreprises/: contact_business
  /newsletter/: newsletter
collections:
  /blog/enfance/:
    permalink: /blog/enfance/{primary_tag}/{slug}/
    template: tag
    filter: tag:enfance
  /blog/:
    permalink: /blog/{slug}/

taxonomies:
  tag: /blog/{slug}/

No I’d like the index to stay on /blog/

edit : oh i realised the blog collection seems to be doing nothing actually so i just removed it, the index is actually on trust_yourself, and /blog/ redirects to /articles/ for product purposes

edit2: nevermind, posts wont load without the blog collection