Last active
August 17, 2020 23:31
-
-
Save mariordev/5fc1391211c9a4df3b5826abf72aa8b1 to your computer and use it in GitHub Desktop.
Quick example of how to sort data from a json file in Jekyll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- In this example site.data.items points to a file named items.json in the _data folder --> | |
<!-- Replace "date" with the name of the field you want to sort by --> | |
{% assign sortedItems = site.data.items | sort: "date" | reverse %} | |
<ul> | |
{% for item in sortedItems %} | |
<li>{{ item.title }} {{ item.date }}</li> | |
{% endfor %} | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for the response!
I tried this approach on my page, but the data is not being retrieved.
I entered the following:
My data file is located as follows:
/_data/events/project1.json