So if the date is in the frontmatter, Can Jekyll use this data to order posts??
Could you have multiple ways of ordering post based on whats in the frontmatter???
{% assign sortedPosts = site.post | sort: 'date' %}
or
{% assign sortedPosts = site.posts | sort: 'anyFrontMatterVariable' %}
you can now loop like {% for post in sortedPosts %}
...
Note : Sorting in the loop like {% for post in site.posts | sort: 'date' %}doesn't work
Beside date there is a way of ordering post based on whats in the YAML Front Matter
Add
weightin the YAML Front Matter of your posts
post #1
---
...
weight: 1
---
post #2
---
...
weight: 2
---
Then sort them like this:
{% assign posts = site.posts | sort: 'weight' %}
{% for post in posts %}
..your code
{% endfor %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With