Help with dynamic routing

Dear Ghosters.!

It’s my first Ghost setup, and i love it.!
Really fast and amazingly easy to work with.

I started customize the Editorial theme to my likeings but the past 24 hours i have tried to get the dynamic routing to work propperly.

I have a few custom pages.

/ (index) - Currently just the index.hbs from the theme.
/blog - uses blog.hbs and shows posts with tag Blog
/projects - uses projects.hbs and shows posts with Projects tag
/about - uses about.hbs
/contact - uses contact.hbs

But my problem is that my posts url’s should be at “site.com/blog/story1” and “site.com/projects/bigproject1” but they are currently on “site.com/story1

My routes.yaml looks like this

routes:
  /about/:
    data: page.about
    template: about
  /contact/:
    data: page.contact
    template: contact

collections:
  /:
    permalink: /{slug}/
    template: index
  /blog/:
    permalink: /blog/{slug}/
    template: blog
    filter: tag:Blog
  /projects/:
    permalink: /projects/{slug}/
    template: projects
    filter: tag:Projects

taxonomies:

Does anyone know what i’m doing wrong here?

Best regards
Henrik

Posts can only live in one collection. Collections are iterated over and “collect” posts. Your first collection has no filter, so it “collects” all the posts. To fix this you need to make your filters explicit with inverse filters:

1 Like

Hi Hannah,

Thank you for your reply.
The inverted filters had no effect on my problem.

Still on “site.com/blog” it shows all blog posts, but im redirected to “site.com/blogpost” and not “site.com/blog/blogpost

Updated routes.yaml

routes:
  /about/:
    data: page.about
    template: about
  /contact/:
    data: page.contact
    template: contact

collections:
  /:
    permalink: /{slug}/
    template: index
    filter: tag:-[Blog,Projects]
  /blog/:
    permalink: /blog/{slug}/
    template: blog
    filter: tag:Blog
  /projects/:
    permalink: /projects/{slug}/
    template: projects
    filter: tag:Projects
  
taxonomies:

I’m running Version 3.11.0

Oh sh**, i must be so tired :slight_smile:

I managed to use uppercase letters for blog and projects tag slugs.
After corrected to lowercase it all works just fine…

Thank you for your help and time.

1 Like