How to Sort Multiple Posts on One Date in Jekyll

This site utilizes Google Analytics, Google AdSense, as well as participates in affiliate partnerships with various companies including Amazon. Please view the privacy policy for more details.

Two Fridays ago on the twentieth of August I did something on this blog I thought I would never do: I published two posts on one day.

For most blog engines - say, WordPress - that’s not a big deal. But this blog runs on Jekyll (via GitHub Pages) so an individual post’s date is specified in its file name.

The two posts I posted have the following filenames:


Only the date is specified, not the time. The question then is… Which post will Jekyll think is first?

It turns out that if the dates are the same, then it is sorted by the “slug.” In my case, that’s the rest of the file name, minus the dash after the date and the dot-file extension.

So would come before With a post on either side of the twentieth, it would be sorted like this:


Confused about what a slug is? Check out the article What the Heck are Content Slugs and How Do I Use Them?

But what if I wanted to come after

Then I would add a date field to the YAML front matter of the latter post:

yml date: 2021-08-20 10:08:39 +02:00

Fun fact: I played around with having a different date than in the filename. When I did this, Jekyll just ignored the file altogether. It’s as if there were no post.

Why the latter post? Because the default “time” set is 0:00 - e.g. “2021-08-20 00:00:0 +02:00”. So setting the time of the latter post, I make it posted later.

Source of my answer: Jekyll gets confused with two post at the same date.

Leave a Reply

Note that comments won't appear until approved.