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.
_site/
to your remote host or is the site being "generated by Jekyll at the remote host" with eachgit push
? – ashmaroligit push origin master
to push content to github repo and then I have a hook that automatically deploys the website online (on Netlify) on each git push. b) I deploy the_site
folder directly on Netlify. a) doesn't work. b) works. Does that make sense? – Fraktargulp
when I update the repo which includesjekyll build
and a few optimizations so it shouldn't affect the post's dates. Why doesn't this happen when I run the build command locally? – Fraktar