Powershell Cmdlet to Create a New Hugo Post
My quick cmdlet to fire off Hugo new post:
function New-HugoPost {
$root = "C:\dev\pweb" # where website is located on disk
$title = Read-Host -Prompt "enter post file name (hyphens are best separators)"
Push-Location
Set-Location $root
$d = Get-Date -Format "yyyy/MM"
$p = "posts/$d/$title"
Invoke-Expression "hugo new $p/index.md"
& "C:\Program Files\Typora\Typora.exe" $root\content # fire off Typora (markdown editor of choice)
Pop-Location
}
To contact me, send an email anytime or leave a comment below.