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.
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.
2021-08-20-a.md would come before
2021-08-20-b.md. 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
2021-08-20-a.md to come after
Then I would add a
date field to the YAML front matter of the latter post:
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.