Create /blog/ permalink after filtering #blog

I am trying to create a URL similar to domain.com/blog/{slug} when the filter matches tag #blog. This is what I have so far in my routes.yaml

routes:

collections:
  /:
    permalink: /{slug}/
    template: index
  /blog/:
    permalink: /blog/{slug}/
    template: index
    filter: tag:hash-blog

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

This doesn’t seem to work, I have added #blog to all the posts, the domain.com/blog page exists, but there are no posts in it. Not sure what wrong I am doing here but any help is appreciated.

In your collections, put the blog route first.

What’s happening now is that all your posts are already being collected on your homepage and there’s nothing left for the blog route.

Everything should work by putting the blog collection before the default one. Let me know!

I tried this:

routes:

collections:
  
  /blog/:
    permalink: /blog/{slug}/
    template: index
    filter: primary_tag:hash-blog
  /:
      permalink: /{slug}/
      template: index

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

But nothing changes. The blog page is still empty

Is #blog the first tag on your posts?

Yes it is. Tried using tag too but no help

This should work. Can you share your actual routes file?

This is the actual file I put in

Please try this:

routes:

collections:
  /blog/:
    permalink: /blog/{slug}/
    template: index
    filter: tag:hash-blog
  /:
    permalink: /{slug}/
    template: index

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

That worked! Thank you!

1 Like