Chronological order sort for tagged posts

I wish to sort a particular group of tagged posts in chronological order. The default is reverse chronological order. I’m guessing this is done in routes.yaml and have tried several options, but no success. I also searched these forums (and StackExchange) but found no answer.
Here is my latest attempt (which is located within “collections”):

/exam-taking-techniques/:
    permalink: /exam-taking-techniques/{slug}/
    template: index
    filter: tag:exam-taking-techniques
    order: published_at asc

Thanks in advance!

What you have looks right, but the spacing is off. Can you recheck for two spaces for the url and four before each property of that collection. Feel free to post the whole thing for context.

Wow, fast reply! I think I just pasted incorrectly. Here is “collections” again in its entirety as I have it in VS Code:

collections:
  /:
    permalink: /{slug}/
    template: index
    filter: tag:-[newsletter]
  /newsletter/:
    permalink: /newsletter/{slug}/
    template: index
    filter: tag:newsletter  
  /exam-taking-techniques/:
    permalink: /exam-taking-techniques/{slug}/
    template: index
    filter: tag:exam-taking-techniques
    order: published_at asc

Thanks

Collections populate in order. Try putting the most selective ones first.

1 Like

Tried it (see below). No luck. Maybe my theme is getting in the way. The publisher of the theme doesn’t think so.

collections:
  /exam-taking-techniques/:
    permalink: /exam-taking-techniques/{slug}/
    template: index
    filter: tag:exam-taking-techniques
    order: published_at asc
  /newsletter/:
    permalink: /newsletter/{slug}/
    template: index
    filter: tag:newsletter    
  /:
    permalink: /{slug}/
    template: index
    filter: tag:-[newsletter]

One line I wasn’t sure about was the filter: tag: line

I can get this to work in routes side but in collections side it doesn’t seem to apply. I can’t even tell by looking at the Ghost Docs if its meant for anything other than routes…

If I do a route and channel it works flawlessly, this makes me wonder if it isn’t supposed to be a collections control as those would be in the handlebars configuration then?

Ahhh, thank you. It looks like I am mixing some terminology and need to learn more about collections, channels, tags, etc… as they apply to Ghost.
Indeed, I was trying to accomplish this for the tags page. The link to the collection did sort the content the way I wanted but it uses the index header.
I’ll research more before I continue this thread. Thanks everyone so much for your help so far…

1 Like

Maybe my collections did finally sort, now I have oldest first. Definitely should work but depends (I tested on collections for index on the homepage and it did sort).

My boring test:

collections:
  /:
    permalink: /{slug}/
    template: index
    filter: tag:-[courses]
    order: published_at asc

Pretty sure this is meaning you should assemble a actual hbs file for your template instead of using index. I am new and growing overall but I would expect you would format a

exam-taking-techniques.hbs

to use in place of index.hbs

This page would layout what you want specifically to that collection…

Yes, the tag pages are not a collection nor a route, so you want to go make that page (easy enough to sart with a copy of something like index and adjust). You may even be able to adapt form tag.hbs and maybe be closer to the look you want but you need to have some handlebars experience or willingness to learn!

Im having a blast as I am sure you will (as you can see I am splitting off a courses.hbs template so doing a similar thing).

Cheers!

Also good learning on custom hbs for a collection:

Awesome. Thanks so much @digitalresidue. That link helps with the elements of Ghost that I am unfamiliar with.
It does look like a new page is the way to go. Time to learn handlebars! I’ll post my results when they are done. Thanks again! :grinning:

1 Like

Can’t wait to hear how it goes! Ask away as many are at similar places unless @Cathy_Sarisky comes in with her huge brain, though read her posts and blog when you have a chance as they taught me other things to tweak.

2 Likes

You can specify the index.hbs (or tag.hbs) as the template file for your collection. You don’t have to write custom, unless you want to. (Of course, you might want to!) [Be warned that some themes have an index.hbs or home.hbs that makes #get request and ignores routes.yaml as a result. Source is a notable example.]

You may want to put the right side of your filter expression in quotes to be sure it’s getting parsed correctly.
filter: 'tag:exam-taking-techniques'

2 Likes