It is a truth universally acknowledged that an individual in possession of a Hugo blog must feel compelled to make loads of posts about every aspect of their Hugo setup, and I must admit that this instinct has not totally escaped me πŸ˜… At least I write enough about other things to not be in the bottom-right corner of shame on this scatterplot. Today’s post is on something I’ve seen a lot of others grapple with too, namely the tension between wanting to use a static site generator to build a blog, cos it’s lightweight and avoids databases, while also wanting the freedom to update your blog on the go. This is particularly desirable for IndieWeb purposes, so that rather than tweeting on the go, for example, you can always post first to your own site.

There are a number of ways to do this. It seemed to me like the ideal would’ve been to create or adapt a Micropub server, so I could post to my blog from any Micropub client and have those posts translated into Hugo source files, ready to build. But currently, I do not have the programming knowledge to do this. Another popular workflow seems to be using Forestry.io or another CMS layer (even a Micropub server configured for this purpose) to manage Hugo source files stored in a Git repository, and hosting your site on something like Netlify or Digital Ocean’s App Platform so as to have it automatically rebuilt every time you make a new commit. If I were making a site from scratch that could’ve worked for me, but I already had conventional shared hosting and I was too lazy to move. So, I came up with another plan.

My alternate strategy is basically this: I keep a copy of my Hugo source files on the remote server itself, use SSH to create and publish new posts from my phone when need be, and use rsync regularly to make sure my remote copy and my local copy (on my computer) of my Hugo files are the same. For this, you will need to have or be prepared to get some kind of SSH app for your phone; on iOS I use SSH Secure ShellFish, which is a paid app (US$3/month or US$27 as a one-off purchase), but is very good with share sheet integration. Use whatever you feel comfortable with.

Updating my blog at home, from my computer, is very straightforward. I keep a terminal window open in my Hugo directory at pretty much all times, and whenever I want to, I can create a new post in pretty much exactly the way the Hugo Quick Start guide prescribes. To publish it, I could build the site locally and upload the built files, as the guide suggests. However, when I post from my phone I build on the remote server itself, so for uniformity I do the same from my computer.

What I do is rsync the source files, then SSH into the remote server to build there. I set up passwordless SSH and followed this guide to learn the syntax I needed for the rsync. I’ve created aliases – jls_put and jls_get – in my .zshrc file so I don’t have to type out the whole command every time (and risk making typos). Keep in mind the various flags you can use with rsync, and what makes best sense for you. I personally use the flags:

  • -auvzP: “archive mode”, don’t overwrite newer files, give me verbose feedback on progress, compress files for transfer, and give me a progress report – in that order
  • --exclude=config.toml: I have separate config.toml files for my local and remote Hugo directories because they’re stored at different paths on each filesystem; if I need to make changes, I make them manually to the remote file after testing locally
  • --exclude=.DS_Store: if you are on a Mac, these junk files will get sent across to your remote server if you do not exclude them with this flag.
  • --delete: only sometimes, so unlike the others it’s not in my alias! But I do use this with jls_put if I’ve just deleted a load of files I no longer need from my local copy; if I didn’t, they’d come right back next time I ran jls_get.

Once the files have synced (which only takes a few seconds after the first time, as rsync works incrementally), I SSH into the remote server (I have a four-letter alias to make this easy too), cd into the directory where I keep my Hugo source files (which is just under my home directory, so cd ~/hugo), and run hugo.

Posting from my phone is a little more of a hassle – more so than typing something quickly in an app and hitting “Send”, for sure – but is not completely unreasonable. The main issue is that obviously I don’t have Hugo installed on my phone, so I’ve got to create my post files manually. To help with this, I have a number of “template” files saved in my iCloud Drive. For example, my posts.md template looks like this:

---
title: ""
date: 
year: 2021
month: 2021-04
categories:
tags:
draft: true
---

…and to make it easier to post photos, I also have a photo-post.md file that has my image shortcode1 pre-filled, like this:

---
date: 
year: 2021
month: 2021-04
categories:
- Photos
tags:
draft: true
---

{{< img src="filename.jpg" alt="" style="" width="" class="u-featured" >}}

So I duplicate this template to a new file, which for the most part I just have to use a Markdown editor to fill in the way I would any post on my computer. The big exception is the datetime, which I can’t autogenerate, so I have to type it in the exact format Hugo wants. If I want to post a photo, I also need to make a copy and edit that on my phone to resize it and strip out unwanted exif data. But I need to do that to post a photo from my computer, too. Overall, it’s mainly the datetime part that’s a pain compared to computer blogging.

To actually get my new post and any photos onto the remote server, I browse to their location in the iOS Files app, “share” them to my SSH app to upload them to the remote server, then open the SSH app itself, open the terminal on my remote server with one tap, and type cd ~/hugo then hugo. So long as I haven’t created a formatting error through sloppy editing, I’m done at that point. If I have, I fix my error then repeat the procedure in this paragraph.

For the moment, this process works well enough for me, even though there is still a bit of friction. It does the main thing I needed it to do, which is to let me post from my phone. It takes about five minutes for a quick text post, and maybe 15 for a photo post. It’s just enough of a hassle that I don’t do it unless I think my post is worth that kind of time investment, but maybe that’s a good thing – thoughtful sharing and all.


  1. I mentioned it in passing in this post, but I have an image shortcode to enable responsive images, based on Laura Kalbag’s guide. ↩︎