Now that I have custom tasks for building and serving my Hugo site in Visual Studio Code, I wanted to create posts quickly without having to remember the hugo command. So, this is what I did:
| |
The Variable Substitution section of the Visual Studio docs provides information on getting input from the user.
First, I defined the inputs by providing the id, description, and type. Then the most interesting part:
The command:
| |
does three (3) things using bash:
Save the input text into a variable named
title1title="${input:title}"Replace spaces in the
titlevariable with dashes and store the output in another variable namedslug:1slug="${title// /-}"Execute
hugocommand to create the content file:1hugo new content/post/${slug,,}/index.md --source ./srcThis last command converts the contents of the
slugvariable to lowercase. Pretty neat!
So far I’m pretty pleased with my experience with the Hugo static site generator.
