Absolute minimum to scaffold a Hugo static site with a custom theme.
(With some dev tooling added after the fact 😈)
hugo_extended_0.129.0_linux-amd64.tar.gz
)# clone repo
git clone https://github.com/pythoninthegrass/hello_hugo.git
cd hello_hugo
# clone theme submodule
[ $(uname -s) == "Darwin" ] && procs=$(sysctl -n hw.ncpu) || procs=$(nproc)
git submodule update --init --recursive && git pull --recurse-submodules -j"${procs}"
# add a new post
hugo new posts/test-post.md
# start hugo server (with hot reloading)
hugo server
# open browser to http://localhost:1313
# stop hugo server
# CTRL+C
.env
fileProgrammatically generate the hugo.toml via python
and devbox
.
Minimum values in .env
:
Key | Default Value |
---|---|
BASE_URL |
example.com |
LANGUAGE |
en-us |
TITLE |
Hello, World! |
THEME |
ananke |
hugo.toml
devbox install
cp .env.example .env
# edit .env
devbox run gen-config
hugo
If deploying to nginx
, add the following to .env
:
Key | Default Value |
---|---|
NGINX_DIR |
</var/www/html> |
where </var/www/html>
is the path to the nginx
root directory.
Comment out the line in docker-compose.yml that mounts the nginx
certs directory.
volumes:
- ./public:/var/www/public
# - ./nginx/certs:/etc/acme/certs/live/${BASE_URL}
Generate certificates with either acme.sh or certbot.
Copy the following files to the nginx
certs directory:
fullchain.pem
privkey.pem
ssl-dhparams.pem
If developing locally, add the following to /etc/hosts
:
127.0.0.1 example.com
# 127.0.0.1 localhost
Where example.com
is the value of BASE_URL
in .env
.
Remember to revert / comment out the 127.0.0.1 example.com
line and reinstate 127.0.0.1 localhost
when done.
Build and start the nginx
container:
docker compose up -d --build
Navigate to the BASE_URL
in a browser:
http://example.com
https://example.com