I am trying to create a newsletter archive page. I have followed a few threads on the forums but I’m running into issues where it does not work.
Here is my routes file. I have at least one publish post with the tag News. It shows up at /tag/news but not in /newsletters (which is empty besides the header/footer.
routes:
collections:
/:
permalink: /{slug}/
template: index
/newsletters/:
permalink: /newsletters/{slug}/
template: archive
filter: tag:news
taxonomies:
tag: /tag/{slug}/
author: /author/{slug}/
I have tried some variations of tag:News tag:news , would appreciate any insight on what I’m doing wrong here. Thanks!
Try replacing the order of the collections…
/newsletters/:
permalink: /newsletters/{slug}/
template: archive
filter: tag:news
/:
permalink: /{slug}/
template: index
Routes are crazy powerful, but I would not use the word ‘intuitive’.
1 Like
Brilliant! That worked. Good to know the order is critical here. Much appreciated @mheland !!
OK whoops, I spoke too soon.
What this did seems to be:
- News posts on /newsletters/ – great!
- Index page is now completely reset to just an archive page with the exact same content, now working on trying to recover it.
Seems to be some kind of strange caching issue, logged in it was showing me a different result for the home page as when I’m logged out in a different browser. So far it’s holding.
I now have this as my routes list, without the filter, seems to be working ok as a newsletter archive now, fingers crossed.
routes:
collections:
/newsletters/:
permalink: /newsletters/{slug}/
template: archive
/:
permalink: /{slug}/
template: index
taxonomies:
tag: /tag/{slug}/
author: /author/{slug}/
Great, maybe you also want to exclude tags with filters and the minus-sign before…
/:
permalink: /{slug}/
template: index
filter: tag:-notthistag+tag:-andnotthisone
1 Like