Hugo Site Deployment

Fri, Apr 14, 2017

My site is in a directory named alexkatz-hugo. I run hugo on the command line to generate the site into the public directory. The public directory is a submodule.

To deploy my site I run a shell script that clears my public folder, generates the site with Hugo, and commits and pushes my changes.

Before generating the site, my script removes all files and directories from the public folder, except for the .git directory and CNAME file. It is important to clear the public directory because running hugo does not remove previously generated files. If you don’t clear the public directory you may end up deploying drafts or deleted content.