My First Post On Hugo
I have moved to Hugo! It’s been awhile I posted anything although I had few drafts saved and waiting. But I am tired of maintaining Wordpress and paying extra money to Amazon :) And also those annoying comments from bots! Even Google Capture doesn’t help to get rid of them! So now I am hosting myself and Hugo is my tool to blog!
How I did that
Install Hugo
Firstly I installed Hugo and went through their Quick Start guide which basically is going to be your first blog post. Tutorial’s theme - Ananke - looks very cool and is not that different from my Wordpress theme.
Export your blog posts
Secondly I had to install Wordpress plugin to export my blog posts as Hugo posts. This was pretty much simple and worked as is: you just install plugin, run it and download archive with your posts.
In my case only posts folder had meaningful content and I copied all files into the same posts folder in Quick Start guide.
Hugo configuration
Plugin extracts some posts as HTML and by default Hugo blocks HTML as unsafe. I figured that it can be turned off by updating config.toml:
[markup.goldmark.renderer]
unsafe= true
Now you can run hugo server -D and check out all your posts in Hugo. You’ve got your blog ported!
The drawback is that formatting and syntax highlithing will be not the same. I believe there is a way to fix that by actually updating the posts and fixing some import issues (for example removing unnecessary HTML tags or replacing them with proper markdown).
How I run my website now
By default Hugo renders your website into public folder and it’s just a matter of deploying that folder to a web server. It appeared the easiest way for me is to run it on my old desktop computer and I found a very detailed guide how to run Nginx with Let’s Encrypt in Docker. I just had to install Docker Desktop first (my desktop is a Windows machine) and also Git. One thing I should mention is that tutorial is designed to proxy SSL traffic via Nginx (not serve web pages per se), so this is how my configuration differs from original one:
server {
listen 80;
server_name blog.apalagin.net;
server_tokens off;
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
server_name blog.apalagin.net;
server_tokens off;
ssl_certificate /etc/letsencrypt/live/blog.apalagin.net/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/blog.apalagin.net/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
root /usr/share/nginx/html;
index index.html;
try_files $uri /index.html;
}
And Git installation is very usefull b/c it has Git Bash which allows you to run original bash scripts from the guide. Seems most tutorials I find assume all people in the world use Mac :)
And the very last step was to configure NAT for my router to forward HTTP/HTTPS traffic to my desktop and then re-configure Route 53 to resolve my domain with my public IP. And that was it! It took me few hours to “kill” my Wordpress and move to Hugo. And I actually feel much safer with Hugo - it’s just a static website while hackers still trying to attack it using Wordpress vulnerabilities.