Collection: Filters works well on the homepage but breaks under tags section


#1

Hello folks!

This is my first time playing with the collection function. My goal is to filter out some tags from the Ghost’s homepage.

On my Ghost’s homepage the filter works as expected. Cool!

But when I go to my site https://mysite.com/en/tag/about/ and click on a post from there, I’m getting this error ’ 500 Resource not found.’

My ghost version is v2.6.1
I guess something is wrong with my route.yaml

Thanks in advance!
P

routes:

collections:
  /:
    permalink: /{slug}/
    filter: tag:-[how-to,about,under-the-hood]

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

#2

That’s not quite how collections work: Collections define where a post lives. If there is only 1 collection and you filter posts out of it, then those posts don’t live on any route, which == 500 error

It seems like what you’re looking for is a Channel, which is a specific view of content without changing or influencing where it lives, assigned to the home route. Eg:

routes:
  /:
    controller: channel
    filter: tag:-[how-to,about,under-the-hood]

collections:
  /archive:
    permalink: /{slug}/

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

More info


#3

Thanks for jumping in John. You explanation is very clear and I understand where I messed up.

I’m applying this yaml but no filtering occurs on https://mysite.com/en/

To be clear about my domains:

routes:
  /:
    # Filters out few tags from Ghost's homepage
    controller: channel
    filter: tag:-[how-to,about,under-the-hood]

collections:
  /:
    permalink: /{slug}/ 
    template:
      - index

taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

Thank you!


#4

You’re registering the / twice, as a route and as a collection, so that’s conflicting. In my example I moved the main collection to /archive for that reason


#5

I did try did as well (before posting the 3td comment) and I still don’t see any filter applied.

# filters out few tags from Ghost's homepage
routes:
  /:
    controller: channel
    filter: tag:-[how-to,about,under-the-hood]

# redefine the collections as I we can't define /: twice
collections:
  /archive/:
    permalink: /{slug}/
    template:
      - index

# default values
taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

#6

Little hack

Instead of filtering out, I decided to limit to. I can perfectly live with this :slight_smile:

# filters out few tags from Ghost's homepage
routes:
  /:
    controller: channel
    filter: tag:[article,proof]
# excluding: [about,under-the-hood,how-to]
		
# redefine the collections as I we can't define /: twice
collections:
  /archive/:
    permalink: /{slug}/
    template:
      - index

# default values
taxonomies:
  tag: /tag/{slug}/
  author: /author/{slug}/

Issue open on Github


#7

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.