Hi there,
I’d like to find an elegant way to automatically set or infer my last updated date. For example, lets say I have a document like a roadmap. Whenever I make changes, I can include an updated
line in my front matter.
+++
...
updated = "2022-01-26"
...
+++
The problem is I need to remember to add it or change it. I’m human, and sometimes I forget. I feel foolish having to make a 2nd commit just to change the date. It’s a slightly bigger issue if I include detailed changelogs in my commit messages, the last commit is now clobbered by an “oops” entry.
I’d like to find a clean way to either populate this automatically, or have Zola infer it (even as a separate variable).
For example, the last git commit date would work for me.
git log -1 --format=%cd -- content/roadmap.md
# Output: Sun Jan 23 21:16:30 2022 -0500
It is, quite literally, the last time that file changed.
That might not be useful for someone using Subversion, but to my knowledge most services like CloudFlare Pages only support GIT repositories anyway.
For legal documents (privacy policies) you should manually update the date, but I have many casual documents I’d like to just figure-it-out for me. As an example, a section of my personal blog is a notebook. It has topics, but otherwise it’s unstructured, and sometimes I just dump links or snippets in it. Yes I could check GIT if I wanted to know, but 'cmon, magic updates are fun.
Practically speaking, automatically clobbering the updated
variable isn’t a great idea, but a separate git-updated
variable could work.
Any thoughts or ideas? Thanks!