How to use last_modified hook #6
-
#!/usr/bin/env ruby Check for changed postsJekyll::Hooks.register :posts, :post_init do |post| commit_num = if commit_num.to_i > 1 end Hi Alexander, How is this hook used? How do I also update my posts to have this timestamp? And also how is this timestamp used on the static site? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey @groundedtako The last modified hook is a part of the Chirpy Starter. It checks the post history in Git to set the The hook does not modify or add the ---
date: 2024-06-23 07:33:12 +0400
last_modified_at: 2024-06-23 07:33:12 +0400
--- Here is why I do this. I don't want the post to be marked as modified when I fix a typo and commit changes, but I prefer to show the post as modified when I decide to change the content, like adding or removing a paragraph. So basically, I avoid using the hook while it is still in the codebase. |
Beta Was this translation helpful? Give feedback.
Hey @groundedtako
The last modified hook is a part of the Chirpy Starter. It checks the post history in Git to set the
post.data['last_modified_at']
value. So when you make changes to the post and commit changes to Git, the post will show up as modified.The hook does not modify or add the
last_modified_at
in the front matter for a post, but you can add it manually. Iflast_modified_at
is defined in the front matter, then the hook has no effect. So if I define it manually in the front matter, I have manual control over the last modified date.Here is why I do this. I don't want the post to be marked as m…