Setting up this blog
This blog is generated by hugo, a static site generator. My flow is to write it markdown files on my laptop, commit it to a git repository and push it to the machine that's hosting the blog you're reading. Once the push is successful, a post-commit hook runs hugo and generates HTML pages. Nginx serves these pages.
Next, the firewall needs to be configured and optionally, SSL certificates can be provisioned using Let's Encrypt. It's so much better with the pretty green lock icon.
The performance of this site is great because nginx does a great job at serving files. Maintenance is hassle free because git and nginx are stable and all traffic being served is static.
The downtime I experienced is when I botched an OS upgrade that wasn't necessary in the first place.
- Create/update DNS records for your domain
- Install hugo on prod.
[email protected] $ wget
the latest release from here, Linux x64[email protected] $ tar -xvzf hugo.tar
[email protected] $ mv hugo /usr/bin
- Set up git server
[email protected] $ mkdir blog.git
[email protected] $ cd blog.git && git init --bare
[email protected] $ git clone [email protected]:nindalf/blog.git
[email protected] $ cd blog
[email protected] $ git remote add vps [email protected]:blog.git
kr[email protected] $ git remote add all [email protected]:nindalf/blog.git
[email protected] $ git remote set-url --add --push all [email protected]:blog.git
[email protected] $ git remote set-url --add --push all [email protected]:nindalf/blog.git
[email protected] $ git push all
- Pull Git on server
[email protected] $ git clone /root/blog.git/
- Set up post receive hook
[email protected] $ cd /root/blog.git/hooks
[email protected] $ vim post-receive
and paste in the contents from here[email protected] $ bash post-receive
- test that it's working correctly and generating the right output in the right folder
- Set up ufw.
ufw default deny incoming
ufw default allow outgoing
ufw allow ssh
ufw allow 'Nginx Full'
ufw enable
ufw status
- Check result is identical to this
- Set up nginx.
apt-get install nginx
vim /etc/nginx/sites-available/default
server_name blog.nindalf.com nindalf.com www.nindalf.com
- Set up certificates
add-apt-repository ppa:certbot/certbot
apt-get update
apt-get install python-certbot-nginx
certbot --nginx -d blog.nindalf.com -d nindalf.com -d www.nindalf.com
- Follow interactive tutorial
More context
Shoutout to the great tutorials on DigitalOcean!