I have the following front matter for my blog posts created using Jekyll and using the minimal mistakes theme:
layout: single
title: “”
excerpt: “”
seo_title: “”
seo_description: “”
categories:
tags:
Is there a way to specify the time for posts? If I have multiple posts with file names such as 2024-08-01-article-1.md published first & 2024-08-01-article-2.md published later how can I make it such that article-2 appears at the top of the blog? What’s happening right now is that 2 articles with the same yyyy-mm-dd date are displaying in descending order of publishing instead of ascending.
By default, Jekyll uses the date you use in the filename, just as you suggested, so 2024-08-01-article-2.md
is read by Jekyll, and then when it displays the posts, it uses that date.
However, your post should also have a date
field in the YAML front matter. You will find that when you create a new blank Jekyll site, it includes that field. This is a best practice, especially for people like you who may post more than once a day and care about how the file gets displayed.
Using the date field, you can use this format:
date: 2024-08-01
In your case, that does not help a lot because you want more granularity, so you can extend the date format like this, which includes HH:MM;SS
date: 2024-08-01 02:05:54
Technically, Jekyll uses ISO8601, which means you can extend the date to the UTC timezone offset. For example, I live in California, which is -7 hours from UTC, so I represent the date like this:
date: 2024-07-31 19:05:54 -0700
Here is what you should minimally do so you get the sorting right, assuming article 1 was written first and article 2 was written second:
2024-08-01-article-1.md
:
---
layout: single
title: article-1
date: 2024-08-01 02:01:00
excerpt:
seo_title:
seo_description:
categories:
tags:
---
The content goes here...
2024-08-01-article-2.md
:
---
layout: single
title: article-2
date: 2024-08-01 02:02:00
excerpt:
seo_title:
seo_description:
categories:
tags:
---
The content goes here...
1 Like
Thank you so much, it worked like a charm!
Great! I’m glad this worked out for you!
1 Like