04 Mar 2015
An Exercise in Ultimate Geekiness
“Blogging with Hugo from an Android tablet”

The Challenge

As proofs-of-concept go, this has got to be worth several zillion Geek Points. I set myself the challenge to update this blog, working entirely on an Android tablet. Might not sound like much of a challenge on the face of it, until you remember that this blog is built using the Static Site Generator Hugo and kept updated and syncronised using Git [neither of which run natively on Android]

Anyway, wish me luck, Skip. I’m going in!

geekery01
Composing [the beginnings of] this post in Vim on a tablet

[The astute reader will notice that the screengrab above differs from the current text of this post. That’s because I subsequently reworded it to make clear that I was attempting a complete "round-trip" process here, involving composing, building and sync’ing --not merely writing the post on a tablet.]

OK. The above brief intro was created on an Android tablet, as stated. So "back of the net!" for wee me in the 'proof-of-concept' stakes. The reader will, I hope, forgive your humble author if, from here on in, he writes the rest of this post in a more conventional way --on a 'real' computer. Just because you’ve demonstrated something is doable, doesn’t mean it should be done. Getting even the above done was akin to pulling teeth!

Pre-Requisites

OK. Let’s get on with it. Here’s what you’ll need if you want to play along at home:

Debian Kit

geekery02

The first step is to install Debian Kit on your Android device. This is a splendid application which borders on the pure voodoo. It allows you to install a fully operational Debian Linux sytem alongside Android on your device, without requiring chroot jailing or any of that nonsense. And the Debian install will have pretty much full access to the Android filesystem. Surprisingly, it doesn’t seem to slow my old Galaxy Tab down any either --in spite of that being a bit long-in-the-tooth and not that spritely to begin with.

I’ll not go into the nitty-gritty of how to get up and running with Debian Kit. It comes with a pretty comprehensive help file, which explains everything you need to know to get it installed and configured. Debian Kit runs as 'root'. I don’t suppose there’s a huge risk in that, when it’s confined to your tablet, but I have it ingrained in me to always work in a 'normal' user account and use sudo so, after installing, I also setup another user account to work in.

SSH Client

geekery03

You need an SSH client to interface with Debian Kit [and also, in my case to syncronise with Git repos and upload this Android-authored post]. Originally I had ConnectBot installed, which was fine for the normal Debian 'stuff'. But I later found a glitch whereby, when running hugo server to preview my site, ConnectBot wouldn’t take any notice of the CTRL+C command to stop the server, forcing me to use a clunky ps -ax | grep "hugo" to find the hugo server process and kill it. So I switched to Juice SSH and didn’t have any further problems.

Git

After getting up and running with Debian and Juice SSH, I CD’d to my tablet’s SD Card, made a working directory there and then prepared to git clone this site into it, from my Bitbucket repository. That involved using ssh-keygen to generate a keypair on the tablet. I then accessed the id_rsa.pub public key through [File Explorer](File Explorer and added it to my Bitbucket account via their web interface, so I could access my repositories with Git. I did a git clone and waited for my site to download. As I was cloning onto my SD Card [which isn’t the nippiest of storage media], this took several minutes. But eventually, I had a clone of this website on my Android device.

geekery06
File Explorer showing the site repo cloned onto my tablet’s SD Card

Hugo

Next, I used wget to download the latest Hugo binary for Linux Arm to /usr/local/bin and then Cd’d there and linked the downloaded binary to the 'hugo' command with ln -s /usr/local/bin/hugo_0.13_linux_arm/hugo_0.13_linux_arm /usr/local/bin/hugo.

It was time to see whether it would play nice in this unusual Debian environment. To my surprise Hugo worked pretty much "out of the box" --albeit with the slight hiatus mentioned before, when I found myself unable to gracefully shutdown Hugo’s server when using ConnectBot. Even the site generation times were pretty OK; I’d guess under a minute for this site of [currently] just shy of 300 pages. I’d expected it to take a lot longer than that, especially as Hugo was having to read/write everything to SD Card.

geekery04
Starting Hugo’s server

One thing that really surprised and impressed me was that, with hugo server running, I was able to preview my site as normal in Android Firefox at http://localhost:1313. I really hadn’t expected that to work and I’m still not quite sure how Debian Kit manages to make the 'localhost' within the Debian environment be the same as 'localhost' on the Android host system. I suspect it may be done with mirrors or witchcraft --but it’s bloody impressive, nonetheless!

geekery05
Somehow Debian Kit manages to share its 'localhost' with Android

Blogging

Having installed a GUI-less version of Debian, I was stuck with using Vim to compose my post. I do use Vim a fair bit to do text editing on my various servers, so that wasn’t too onerous, considering. I suppose I could have used File Explorer in combo with some kind of Android text editor, to compose the post outside of the Debian environment but, seeing as text editing on any mobile device is an exercise in frustration anyway, I decided to put up with Vim and just write the intro to this post 'au mobile' and finish the rest of the article in a slightly saner environment.

Actually the biggest PITA was getting the image at the top of the article prepared as it involved taking a screenshot in Android then copying this to the site folder on the SD Card [which needed 'root' privileges in File Explorer], then switching back to Debian, and sudo chown-ing the image file back to me again, so I could access it from within Debian. Not something you’d be wanting to do too often!

Pushing the changes back to Bitbucket via git push origin master was also surprisingly quick although, to be fair, this article was still pretty minimalist when I decided to declare moral victory and move over to my laptop to finish it, so there wasn’t much to upload.

Conclusion

I embarked on this daft adventure to satisfy myself that [in theory!] it was possible to blog from your mobile device whilst still using Hugo, in the same way that it is when using other blogging platforms such as WordPress or Tumblr. The challenge of using a static site generator to build the site and Git to update it was never going to be easy, given the limitations of mobile OSes and --at the end of the day, the exercise was never about setting up a blogging environment that I was actually likely to use in anger that often [if at all!] but to establish whether or not it was potentially doable.

Well, I now know that, if I’m stuck in the middle of nowhere with only an Android phone or tablet for company and "the most interesting thing evarrr!©" happens and I simply have to blog about it, I can keep my devoted readership informed.

Just don’t expect the "press" to be particularly "hot"!

Meta

TAGS: androiddebiangeekinesshugogitlinuxvimblogging

ORIGINAL PUBLICATION DATE: 04 Mar 2015

AUTHOR: stíobhart matulevicz

LAST MODIFIED: 25 Apr 2020  — REASON: "extract asciidoc preamble into separate file and include it"

Back to Top