Custom collection route to filter posts by year

Hi,

is it possible to add a custom route like this:

/year/2018

which would filter the posts by year and have optional /page/2 etc available?

I tried with
/year/:
permalink: /year/{year}

but this acts as an entry, not a collection (entry route is used).

This should work:

routes: 

  /year/2018/:
    controller: channel
    filter: published_at:>'2018'+published_at:<'2019+page:false'

But then you need to route for each year manually. Another more advanced solution is to route “/year/:year” and in a custom template read the “:year” slug. Then use it to get posts by year using handlebar helpers.

Thanks, how exactly should yaml entry for “/year/:year” look like, I can’t get it working :confused:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.