When working with Hugo-based blogs, maintaining up-to-date timestamps in your Markdown files is essential for proper content organization, but it’s easy to forget this when you update the blog.
While Hugo can automatically generate timestamps based on file modification times, you might need to manually update them for specific reasons, such as backdating or scheduling content. This blog post will guide you through using Visual Studio Code (VSCode) to efficiently update timestamps in your Markdown files.
Prerequisites
-
A Hugo-based blog setup… Obviously
-
Visual Studio Code… Also, Obviously, we mention this in beginning of the blog! :D
-
Auto Time Stamp update plugin for VSCode Auto Time Stamp
Install this plugin and use it’s magic.
Add to recommended plugins:
And, add the plugin to Workspace recommendation so that when you open your mark down files on new computer, you can update the blog.Update plugin settings
Once you have installed the plugin, press Ctrl+P
(Windows/Linux) or Cmd+P
(macOS) to update the Plugin Settings.
The following settings have to be updated for the plugin. @ext:lpubsppop01.vscode-auto-timestamp
1"lpubsppop01.autoTimeStamp.modifiedTimeStart": "date : ",
2"lpubsppop01.autoTimeStamp.momentFormat": "YYYY-MM-DD"
Make the settings local
Use above setting for VSCode Folder / Workspace. This way, settings remain local to the blog folder.That’s it… Save your markdown file
Press Ctrl+S
(Windows/Linux) or Cmd+S
(macOS) to save your changes.
Now, the date time will up updated based on date when you last edited your file.
Avoiding this auto update
By default, the plugin Auto Time Stamp works on the first 5 lines of the file. Just add few lines of empty or verbose comments in the header section of the file, and the plugin won’t update time stamp if you don’t want to.
Comments