Hugo

How to build a static website with Hugo




Generate a static website with Hugo

pacman -Syu hugo
hugo new site wildw1ng.com
cd wildw1ng.com

Download a theme

git init
git submodule add https://github.com/McShelby/hugo-theme-relearn.git themes/relearn
hugo new _index.md
hugo new --kind chapter arch/_index.md
hugo new arch/installation.md

Preview the website

hugo server

http://localhost:1313


Build the website

hugo -D

A public folder will be generated, containing all static content and assets for your website which can now be deployed on any web server.


Deploy the website

~/bin/publish
#!/bin/bash
echo 'Build static site' &&
hugo -D -s ~/sites/wildw1ng.com/ &&
echo 'Change the owner to user' &&
ssh archlinux-nginx 'sudo chown -R wildw1ng:users /srv/http/wildw1ng.com' &&
echo 'Delete old website data' &&
ssh archlinux-nginx 'rm -rfv /srv/http/wildw1ng.com/*' &&
echo 'Upload new website data' &&
rsync -ra --info=progress2 ~/sites/wildw1ng.com/public/ archlinux-nginx:/srv/http/wildw1ng.com &&
echo 'Change the owner to root' &&
ssh archlinux-nginx 'sudo chown -R root:root /srv/http/wildw1ng.com' &&
echo 'Show new website files' &&
ssh archlinux-nginx 'ls -la /srv/http/wildw1ng.com'
chmod 700 ~/bin/publish