Create Your Markdown Files From Template
Markdown is incredibly useful, especially for text management. I use it extensively for almost anything related to text. Most of the time, I like to keep file structures the same across a project. Using a template file really helps with that. And since Markdown doesn’t have something like @date
to automatically add the current date, we can just take care of that ourselves too.
To automate the generation of a markdown file from a template, you need template.md
file and a bash file create.sh
.
Markdown template
Basically, a template file is the same as a normal Markdown file, but without specific content. I like to add headings or empty tables that are unlikely to change, as well as meta-information such as the date and title. Here’s an example of a template file.
1 | | Created | Title | Tags | |
Bash command
To automate the creation of a file, we can use the powerful hash
command. Here’s an example:
1 | # create.sh |
Depending on whether you want to handle variables in your template, you can uncomment the appropriate option.
Usage
In the terminal, simply use:
1 | ./create.sh "file name" |
A file named YEAR-MONTH-DAY-File-Name.md
will be created in the current folder, with the date and file name pre-filled.
If you got permission denied. Run this command
1 | chmod +x create.sh |
Create Your Markdown Files From Template
https://xiaoque.github.io/2025/04/12/Create-your-markdown-files-from-template/