Hugo on-the-go!
Background
I am currently writing this blog entry on my phone!
Hugo has been the backend for this blog for a number of years now.
I tend to mostly curate the blog while travelling, and that means always carrying a laptop with me. While this is usually not a problem, when going on shorter trips - I sometimes want to travel lighter, and lugging around a laptop with all its cabling and peripherals can take up both space and weight.
The Problem
For one such upcoming trip, I have been investigating ways to travel lighter - specifically thinking about whether I could forgo taking a laptop with me altogether.
While the convenience of having a laptop with me is nice, one of the few reasons for absolutely “needing” it are to update the blog while I am away.
Termux
“Wouldn’t it be nice to have access to a Linux shell on my phone? If Windows can do it, surely an Android phone could too?”
One quick search later uncovered Termux.
Termux is a terminal emulator and Linux environment app for Android. It provides a command-line interface and a minimal base system that can be extended by installing additional packages. And it does so without requiring root access to the phone!
Frankly, something that should have been included with Android since the beginning?
Packages
Termux doesn’t come with much installed out-of-the-box, but there’s plenty of packages available in the repositories. I’ve barely scratched the surface, but was able to find everything I typically want to install on a fresh Linux environment.
- Tmux:
pkg install tmux
- Neovim:
pkg install neovim
- Hugo:
pkg install hugo
I was also able to apply my standard dot-files
, giving me a familiar and highly-functional command-line environment setup within minutes.
Access Local Storage
By default, Termux does not have permission to read from the phone’s local file-system. This is important for me, as I need to access photos that will be uploaded to the blog.
There is a quick and convenient helper for setting this us, which can be run as an additional step after installation:
termux-setup-storage
Issues
There is one lingering issue that I am yet to solve; fonts.
My Neovim
configuration makes use of certain glyphs that are seemingly not available in the default font. The default font is fine (I am still using it now), but figured that I would need to install something more suitable to solve the glyphs issue.
Apparently this is quite easy, and all you have to do is:
- Download a
TTF
type font - Move to
~/.termux/font.ttf
- And run
termux-reload-settings
That seemed to partially work, in that the default font is no longer used, however - all of the substitute fonts I tried were rendering poorly for some reason.
Will continue investigating. UPDATE: Install Termux:Styling. All issues self-resolved after using this plugin, which I should have just installed in the first place.
Going Forwards
Apparently Termux supports X11 to an extent, so I am keen to try that out soon too.
Summary
With the above setup and configuration out of the way, I was able to author a new blog post just as easily as if I had been doing so on the laptop.
I am very pleased with this outcome (and it was all possible on an un-rooted phone)!
TL;DR
Phone + Termux + Hugo = Blogging on-the-go.