Spell Check, Build Your Site with Hugo, Publish to GitHub

So, you are happy with the preview provided by the local Hugo server, and you want to publish your site. Make sure git status doesn’t show anything uncommitted changes (you do keep versions of your project under control, don’t you?). Then, manually or with some shell magic, change the draft front matter parameter to false for the pages you plan to publish. Restart your Hugo server without the -D option and check that nothing is missing. git diff should also be quite handy, especially after scripted mass-changes. If everything looks good, commit again and proceed to

Spell Checking en Masse

Your editor certainly has a spell-checker, and I’m sure you use it diligently, but checking before publishing is still a sane idea, since we, humans tend to forget and overlook things. This time, we want to spell-check everything we are about to publish en masse, and make sure it’s everything:

grep -rlP 'draft:\s+false' kontent/ | xargs -o -n1 aspell check --sug-mode=slow -x --mode=markdown

The above works if you are using BSD version of xargs. For the GNU version (Linux) it looks uglier, but can be factored out into a function:

grep -rlP 'draft:\s+false' kontent/ | xargs -o -n1 sh -c 'aspell check "$@" --sug-mode=slow -x --mode=markdown < /dev/tty' whatever

Commit when done.

Build Your Site with a Four-Letter Word

hugo

That’s it. Your site is generated in public directory of your project by default. Make sure you put it into .gitignore of your project, or, better still, configure it to be outside your project tree altogether with publishDir: <PATH> in your main configuration file.

Host Your Site on GitHub

There are plenty of other hosting options, but this one combines zero budget with full control over your code. The drawback is that you won’t have an access to HTTP headers (at least as of this writing), and so caching for all content will be set rigidly to 10 minutes.

Create an account at GitHub , if you don’t have any yet. It’s free, and they won’t spam you.

Create a repository named <YOUR USER NAME>.github.io. Go to settings, and enable GitHub Pages for this repository.

In your project’s publishing directory, initialize a new Git repository, add the files, and commit. Set the remote to be your <YOUR USER NAME>.github.io, and push to it. Your site will be available at http://<YOUR USER NAME>.github.io.

Should this URL not satisfy your ego, you can use your own domain. There is an excellent GitHub tutorial , so I’m not going into details here.

That’s it!

Built with Errorist theme for Hugo site generator.