0x00 - Deploy your Hugo Site in the blink of an eye with Docker
Introduction
This article was written in response to a need I encountered: there was no simple Docker image to install and manage a Hugo site. So I decided to create my own solution from scratch.
My goal was to create a Docker container capable of easily deploying a Hugo site, meeting the following criteria:
- On first run, a new site must be created if it doesn’t already exist.
- If a site with the same name already exists, the Hugo service should simply launch.
- Offer users a simple, clear theme (e.g. Stack).
- Offer two default languages: English and French, to simplify configuration.
In this article, I’ll present two installation methods: a simple version and a version using Nginx Proxy Manager.
Creating the docker-compose.yaml file
Let’s start with the simple method. Run the following commands to create and edit your docker-compose.yml file.
|
|
Edit the file and copy the following content:
|
|
Then launch Docker Compose :
|
|
If all goes well, you will be able to access your site at the following address: http://127.0.0.1:1313.
Configuration with Nginx Proxy Manager
Here’s the configuration I’ve set up on my personal server with Nginx Proxy Manager. This method differs in that it creates two networks: one for Hugo and one for the Proxy. This improves security, as the Hugo network is dedicated solely to communication with the Proxy network.
Start by creating your docker-compose.yml file :
|
|
Edit the file and copy the following content:
|
|
Then launch Docker Compose :
|
|
All that’s left to do is configure your proxy to set up the redirection, and you’re done. Here’s how I set up the redirection on my end:
Image 1 | Image 2 |