How to avoid update time error when deploy hexo blog using CI CD
A long time ago, I have found my post update time will be changed if I delete and regenerate the file and I do not take care of this small problem. And now I have found all my post was add the modified tag, whose time is the same as time I compile. Today I find the reason and solution finally.
Reason
Hexo uses file modify date as update time by default if you do not clarify this parameter in front-matter of post. CI CD in Gitea always delete and recreate file so file’s modify time changed frequently. So we can change the default settings and clarify this parameter manually to avoid this problem.
Solution
Edit your _config.yml
file.
1 | ## updated_option supports 'mtime', 'date', 'empty' |
Then hexo won’t view modify time of file as post update time if do not clarify it. And you need to update hexo no earlier than 5.0 following my post before.
Edit your /scaffolds/post.md
file.
1 | --- |
Then you will generate updated time parameter automatically when create new post.
Have fun with your new version hexo!