Jekyll: can't sort collection by date -


this making me crazy.

i have collection resources:

# _config.yml collections:   resources:     output: true     permalink: /resources/:name/ 

they have dates:

# /_resources/example.md --- title: learn web date: 09-04-2013   --- 

the pages generated, , if try display it's date, displayed correctly, want sort date, , doesn't work. doing wrong?

{% assign sortedresources = site.resources | sort: 'date' %} <!-- doesn't work --> {% resource in sortedresources %}   <div>     {{resource.title}}     <small>{{resource.date | date: "%d %b %y"}}</small> <!-- works -->   </div> {% endfor %} 

i'm using:

▶ ruby --version ruby 2.1.4p265 (2014-10-27 revision 48166) [x86_64-linux] ▶ jekyll --version jekyll 2.5.3 

thanks

i'm experiencing same problem collections.

while trying sort on european formatted dates dd/mm/yyyy or dd-mm-yyyy, string sort. when timezone: europe/paris set in _config.yml file.

the way collection sorted date use format yyyy-mm-dd.

# /_resources/example.md --- title: learn web date: 2013-04-09   --- 

and sort working.

edit - how jekyll manages 'dates':

date: "2015-12-21" # string date: 2015-12-1    # string d not 0 paded date: 01-12-2015   # string french format date: 2015-12-01   # date date: 2015-12-21 12:21:22  # time date: 2015-12-21 12:21:22 +0100 # time 

if don't need time can stick date: yyyy-mm-dd format. , have consistent across collection. if mix string, date and/or time liquid throw error liquid error: comparison of date time failed or liquid error: comparison of string date failed


Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -