Running Hugo on Android

I’m traveling for Christmas this year, and I wanted to see if I could do some blogging on the flight, using only my Android phone, without any internet connection.

My blog is built using Hugo, which lets me write my posts in Markdown files stored in a git repository. A few things have changed since I blogged about how I set it up in Azure, but most of it remains the same.

So I figured, why not do the most meta thing possible, and blog about how blog on the flight, on the flight?

Stage 0: The Apps

I had about an hour left at the airport before boarding, and I needed to figure out a few things:

  1. Can I clone a git repository to my phone?
  2. Are there Android apps for editing Markdown?
  3. Is it possible to run Hugo locally to see changes?

Spoiler: Yes!


After doing some research, I quickly stumbled upon Termux, a terminal Linux environment for your phone. Before you search for it on Google Play, know that the version published there is old and won’t help you all the way through this post.

You will need to download the app from the GitHub repository under the releases.

Termux empty terminal


The second app I chose is called Markor and is a competent Markdown files.

Markor Markdown Editor

I downloaded this one from Google Play, but it’s also available at the open source GitHub repository.

Stage 1: The Setup

I had the apps in place, but I was running out of time before the hard deadline of boarding, which would mean no internet.

If I couldn’t set it up and get it working, I would have to spend my flight doing something less productive, like watching Netflix or playing Nintendo Switch. The horror!

First of all, I needed to grant Termux permissions to browse and handle the storage on my phone.


After running the command and granting the permissions, I needed to install the tools for the actual blogging.

First I wanted to upgrade all the built-in tools to their latest versions, and then install git. Running the commands below will do that, using a pre-registered package feeds in Termux.

pkg upgrade
pkg install git

I now had git, but the next issue was authenticating to GitHub, since my blog repository is private. I decided to solve it quickly by also installing the GitHub CLI and logging in, so I could clone it.

pkg install gh
gh auth login

Markor created a directory when I first started the app, which I decided would be where I would clone my blog to.

cd storage/shared/documents/markor
git clone <git-repo>
cd PipeHow

Finally, I needed Hugo.

pkg install hugo

Stage 2: Hugo on Android

Go to gate

I figured I was done with the setup, feeling ready to get on the plane, when the sign turned on for everyone to start queueing, but it wasn’t going to be that easy.

I took my bag over to the gate and ran the command hugo server -D in Termux to start a local web server for the blog, including draft posts.

Hugo Server Error

It didn’t work. I started frantically googling for a solution, and when I turned my head up to the monitor to see how it was going with the flight, I saw that it was delayed. I had a chance to figure it out!

I found some old forum posts from other people who had tried to do the same thing, who said that it used to work with Termux, but after a Hugo version upgrade it no longer did.

Maybe I could downgrade to an older Hugo version for the flight. I stayed exploring the pkg install command, but quickly saw that there was no way for me to downgrade the Hugo installation, the package feeds in Termux only hosted the latest versions. For a moment I thought that I would have to download an older Hugo release from the GitHub repository, figure out how to unzip and install it, and hope that it would solve my issue.

Then I saw it. A parameter called --noBuildLock had been added in a later version, to skip creating the build lock file. I went back into Termux and tried it.

Hugo Server Working

It worked!

Blog running locally in browser

Stage 3: Blogging

I had a lot of fun figuring out how to write this blog post. Not only is it really cool to be able to run Hugo locally on Android while being offline in a plane, but I was pleasantly surprised with how well it worked to write using Markor.

There’s syntax highlighting, pre-made templates even for Hugo markdown files with front matter, and it’s just as easy as writing anything else on your phone.

It also blew my mind that I could run a Linux terminal inside my phone so easily, and do stuff that I’m used to doing in other shells.

As a conclusion, I managed to get on the flight with just enough time left to figure out which URLs I needed to save for references throughout the post before I had to turn airplane mode on. In total, I spent around 2-3 hours on figuring out the tools and writing the blog post, and as of writing these last sentences there’s about 15 minutes left before I land safely, turn off airplane mode, and run the following code in Termux so that you can read this and enjoy the same experience:

git add .
git commit -m "Blog Post: Running Hugo on Android"
git push


comments powered by Disqus