Improving My Blog Workflow

Reading time: 3 minutes (590 words)
Author: @pugmiester
Tags: blog , localhosted , selfhost

I’ve been thinking about this for a while now but I now have a solution. It’s not perfect, but it’s better than what I had before. I’m gettting ahead of myself.

When I decided to start a blog, back around April 2023 (wow, I just realised my blog is already over a year old), I wasn’t really sure how I was going to create the content and get it online. I settled on using the Hugo static site generator with one of the many themes. As I was sat working from my Chromebook at the time, I used the built in Linux shell to get everything setup. I downloaded Hugo and the theme and set about creating content which was then uploaded to my third party hosted web server using rsync.

Fast forward a bit over 12 months and things are mostly the same. I was still using my Chromebook to create the posts but now I’m hosting the site from home (See New home for my blog for more details). I’m using a private Codeberg repo to backup everything from my Chromebook as I save and depoy new stuff and I’m using the issues as a place to rough out and record new content so it’s accessible frrom any machine but I’m still locked to my Chromebook for creating the content and getting it published.

As I mentioned at the start of the post, I’ve been thinking about a better way to do this so I’m not locked to a single machine for content creation and I finally have that working now. It’s nothing earth shattering, and I’m certain there are better ways to do this but for now this works for me. So what did I do?

What wasn’t working was that Hugo has a way to run the server component locally so that you can check your content before uploading it to the webserver. The problem was, by default it assumes you’re working on the same machine, which was the case when I was using the Chromebook, but now I’ve separated the machine hosting my build environment from the machine I’m using to create the contents, running a service listening on http://localhost:1313 isn’t very practical. A few minutes of searching pointed me in the right direction though. It’s possible to have hugo’s local server bind to the host machines LAN IP and you can also feed it with a base URL so with a local DNS entry for the server, I can host a local copy of the site for checking for page layouts and typos.

Knowing I’d never remember the syntax, I created a shell script to do the work for me.

#!/bin/bash
# hugo-server.sh
# This script is used to start a copy of the Hugo local server, bound to the LAN IP of bloggy.lan
hugo server --bind [REDACTED IPv6 Address] --baseURL http://bloggy.lan:1313/

Now I had a way to create my content from any machine by SSHing into bloggy.lan at home (or remotely using Zerotier) using any client device and creating a new Hugo page, adding stuff and previewing it using the hugo “local” server to check for any obvious issues before I deploy it to my #localhosted web server.

As I said, I’m sure there are better ways to do this but for now it works for me.