I’ve recently switch my web site to be a static site built with hugo and hosted on github’s pages. Being a statically generated site, hosted on somebody else’s computer, this setup is significantly more secure than my previous wordpress site, should be faster, and less prone to disappearing due to a server failure.
Hugo has a quite useful explainer on how to host a hugo site on github pages, including the use of magic submodules to maintain a source repository and a public website repository.
Where they and I diverge however, is in the script to deploy. I primarily use windows computers, and powershell is more readily available than bash. So I wrote a powershell deploy script that roughly mimics theirs, and also commits and pushes to the source repository.
I simply saved this in my source repo as deploy.ps1, then hen I need an update, run ./deploy.ps1
.
#build site
hugo -t academic
# add files to git
cd public
git add -A
#set up commit message
$msg="rebuilding site " + (Get-Date)
If ($args[0]) {$msg = $args[0]}
#commit and push public repo
git commit -m $msg
git push origin master
#and back out and commit and push source repo
cd ..
git add -A
git commit -m $msg
git push origin master