URL does not change when configuring collections in routes.yaml

I’m trying to create an area on my website where I have posts related to my fantasy world.
so, essentially, I tried to define a route with the channel controller and also define a collection in my routes.yaml.
But, what I don’t understand is why the URLs of the posts themselves don’t change. I want the URLs to change in relation to the area they are in. Whether it’s a newsletter or a fantasy world post. Below is my Routes.yaml. I would appreciate it if anyone can tell me what I’m doing wrong to configure this thing:

routes:
  /subscribe/: members/subscribe
  /signup/: members/signup
  /signin/: members/signin
  /account/: members/account
  /upgrade/: members/upgrade
  /newsletters/:
    filter: primary_tag:Newsletter
    controller: channel
  /thedragonsempire/:
    filter: primary_tag:DragonsEmpire
    controller: channel

collections:
  /:
    permalink: /{slug}/
    template: index
    filter: tag:-Newsletter-DragonsEmpire
  /thedragonempire/:
    permalink: /thedragonsempire/{slug}/
    template: custom-full-feature-image
    filter: tag:DragonsEmpire
  /newsletters/:
    permalink: /newsletters/{slug}/
    template: custom-full-feature-image
    filter: tag:Newsletter

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

My website is https://orencreates.com
I have a live example of the issue. You can go here to this collection and see a test post there but when you click it, you’ll see it doesn’t appear with the right URL:
https://orencreates.com/thedragonsempire

Thank you for any help in solving this issue!

It looks like there are couple of mistakes in your routes.

  1. Tags should be written in lowercase, because they should be tag slugs, not tag names. tag:dragonsempire, tag:newsletter
  2. If you are creating collections, I guess there is no need for adding routes as well.
  3. The syntax for excluding these 2 tags looks wrong. It should be tag:-dragonsempire+tag:-newsletter

Here is the new routing which I tested on my end.

routes:
  /subscribe/: members/subscribe
  /signup/: members/signup
  /signin/: members/signin
  /account/: members/account
  /upgrade/: members/upgrade

collections:
  /:
    permalink: /{slug}/
    template: index
    filter: tag:-dragonsempire+tag:-newsletter
  /thedragonempire/:
    permalink: /thedragonsempire/{slug}/
    filter: tag:dragonsempire
  /newsletters/:
    permalink: /newsletters/{slug}/
    filter: tag:newsletter

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

Ok so the solution was a combination of your comment and mine. When I used your routes.yaml, I couldn’t access the link: orencreates.com/thedragonsempire I was getting a 404.

But, when I put only the routes back in, it worked like a charm! So, if you can edit your answer to remove your second bulletin and change the routes.yaml accordingly, I’ll mark it as the right answer for the people that will come looking for it after us :slight_smile:

Hey, glad to hear it worked. I was confused, because it worked on my end without the values entered in routes. After looking at the yaml values for a while, I found the issue.

If you look at the routing file entered in your question, the URL entered in routes: is /thedragonsempire/ (with an “s”) while the one in collections: is /thedragonempire/ (without an “s”).

And my version is without “s” and that’s why it’s giving 404 at orencreates.com/thedragonsempire

Here is the new version with the correct URL (with “s”)

routes:
  /subscribe/: members/subscribe
  /signup/: members/signup
  /signin/: members/signin
  /account/: members/account
  /upgrade/: members/upgrade

collections:
  /:
    permalink: /{slug}/
    template: index
    filter: tag:-dragonsempire+tag:-newsletter
  /thedragonsempire/:
    permalink: /thedragonsempire/{slug}/
    filter: tag:dragonsempire
  /newsletters/:
    permalink: /newsletters/{slug}/
    filter: tag:newsletter

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

Wow! incredible find! I totally didn’t notice that and you also saved me some routes! Thank you so much! :slight_smile:

1 Like