Skip to main content

TCFJR

Hugo tweak

Here’s a tweak I made to my Hugo workflow to default the draft setting to false, instead of the default of true.

I use a small bash script (hpost.sh) to create new Hugo posts for each of the three blogs I’m currently using. The script handles the command line argument that selects the blog, with the default being the primary. It does some validation checks, then runs hugo new to create the markdown file.

hugo new defaults the draft value in the front matter block to true, but in my one-man-show workflow I always want draft set to false. Hugo doesn’t provide this directly, so you either need to manually change it during your edit, or use a script to do it for you. I chose to use the script.

In hpost.sh, I added this line just after the hugo new command:

sed -i -e 's,^draft = true,draft = false,' $filename

where $filename is the name of the new markdown file.