Tips for Hugo Websites
Here’s how I setup my blog with Hugo, I hope that some of these tips may be helpful to you.
Setup git on your remote server⌗
|
|
Setup a hook to generate your website:⌗
Please note that SITE in this section really is the variable $SITE and not the value setup above.
Continue in the same directory:
|
|
Create your website’s directory⌗
Your website’s document root will be tracking your git repository and automatically updated by the hook above, but in order for a web server to serve it, it needs to be there.
|
|
Setup the web server⌗
For my example, I’ll be using Apache httpd. In short, the configuration below…
- redirects http to https (and provides a path for Let’s Encrypt certificate renewal)
- points to the public directory were he pages are generated
- setups a 404 page pointing to Hugo’s 404 page; as I migrated from another blog engine, I wanted to keep some link compatibility so I’m using server side includes to auto generate the link, but only on 404.html.
|
|
Quick Start Hugo…⌗
Now you’re ready for the first steps of the Hugo instructions, from the [Quick Start][https://gohugo.io/getting-started/quick-start/]…
Step 1: Install Hugo⌗
This step may widely vary on how you install Hugo, so it is out of scope for this entry.
Do this both on your server and on your own computer.
Step 2: Create a New Site⌗
Wait, what about Git? Let’s not forget about it…
First, clone your repository, then initialize your Hugo website and commit the newly generated files.
|
|
Step 3: Add a Theme⌗
At this point you should only add the git submodule of your theme, also I preferred to use the configuration in yaml format rather than toml, but it’s your taste, do as you wish. :)
You’ll need to commit your changes to your server’s git:
|
|
And now you need to go back to your server and change into your.web.site’s document root directory in order to pull the changes and initialize the theme’s submodule:
|
|
Step 5: Start the Hugo server⌗
You can skip this step if you don’t care much for drafts, and you already have your own web server, don’t you? :)
Step 6: Customize the Theme⌗
On your computer, edit your.web.site’s configuration file (config.yml or config.toml) and adjust the values accordingly.
One configuration you may do just now is to take advantage of that 404.html magic mentioned above, remember that?
Create a layouts/404.html with the following content (please, adjust to suit your fancy):
|
|
Remember to git add, commit, and push so your changes get published by the git hook, which will take care of running hugo -D for you.
And now enjoy the beginning of your publishing with Hugo.