Unexpected behavior with routes

I have following routes set up:

collections:
  /music/:
    permalink: /music/{slug}/
    template: index
    filter: primary_tag:music
  /newsletter/:
    permalink: /newsletter/{slug}/
    template: index
    filter: primary_tag:newsletter

The second one works as expected and has only the post with the primary tag “newsletter”. But the first one shows all posts, regardless of the primary tag on the index page.

Curiously the URLs are correct according to the route settings, i.e. both /music/ and /newsletter/ posts are included in the first collection.

Am I missing something?

Thank you!

Post your index.hbs file?

It is the index.hbs of the default theme:

{{!< default}}
{{!-- The tag above means: insert everything in this file into the body of the default.hbs template --}}

<main class="gh-main">
    {{> "components/post-list" feed="index" postFeedStyle=@custom.post_feed_style showTitle=true showSidebar=@custom.show_publication_info_sidebar}}
</main>

Meaning Source? Source makes a #get request (it may be within the partial called in your example - see partials/components/post-list). That get request does not respect routing.

Thanks! I guess, I need to dig deeper here then.
However, I’m wondering why the second route works as expected. It is the same index page. Also, is it possible to achieve the indended behaviour, displaying two separate collection, without custom templates?

For Source, I there’s a ton of ‘get’ behavior going on with the index template, which calls this partial:

You may want to look at Casper instead, which does respect routing.

Many thanks! I’ll check out Casper.