This is the solution I've used to sort posts by last-modified-date
: Sorting Jekyll posts by modification date instead of posted date?
Jekyll::Hooks.register :posts, :pre_render do |post|
# get the current post last modified time
modification_time = File.mtime( post.path )
# inject modification_time in post's datas.
post.data['last-modified-date'] = modification_time
end
In development it works perfectly, as expected. All post dates are correct.
If I go through git before deploying to my host it's not working. All posts display last modification dates = commit dates (as far as I can tell). It essentially shows all posts were updated at the exact same time.
If I skip git and deploy the site on my host directly, again, it works as expected.
Note that I'm not using Github Pages to host the website.
Is there any way I could fix this issue? I'd like to keep version control for my project.