Developing A Blog On Android

October 2023 ยท 5 minute read

Since the techie side of this site is more towards the blogumentation side of things I thought it prudent to write down the steps that I’ve taken so far to allow me to maintain this site on an Android device, specifically a Samsung Galaxy Tab S6 Lite in my case, but in theory these steps will work on any up to date Android device.

If you care more about the how of it all and less the why (you might have your own reasons for wanting to edit code on an Android tablet) then jump past the ‘Why’ section.

Why?

Why on Earth would anyone want to edit the content of a website on an Android device? And even more so why is this remotely techie? Surely it’s just editing a CMS? Well….no.

So why Android? Firstly, I don’t want to buy a new laptop. So if you have a laptop that suits your needs then this guide is not really for you. Mine is big and clunky. My android tablet less so. Secondly, it’s one less device to have laying around the place right? Who doesn’t want that?

The techie side? This is where the technology I’m using to host this blog comes in. I’m trying to be a cheapskate because who knows where this blog might go. It might only ever be me posting random topics, so I’m being a bit of a cheapskate. This blog is hosted in GitHub Pages (free) and developed using the static website generator Hugo (also free). It’s also just fun being able to learn new things.

Getting Termux

Termux is an android terminal emulator and Linux environment app. To use it for our purposes we don’t need root and we don’t need to install any Linux distributions. It’s as simple as getting a hold of the app. The small caveat is that the latest version of the app is no longer available in the Google Play store. Personally I dowloaded the app from F-Droid as per the developers recommendations: https://termux.dev/en/

Git good

I’m storing my website code in GitHub, so being able to pull code and create branches is a useful thing to have. Now that Termux is installed getting git up and running isn’t much of an issue. All these commands should be run inside the Termux terminal.

As with most things in life make so we update and upgrade first:
apt update && apt upgrade

Next install git and openssh for authentication:
apt install git openssh

Setup the storage for Termux
termux-setup-storage

Create a Key-Pair for SSH
ssh-keygen -t rsa -C "email_address"

Log into GitHub
ssh -T [email protected]

This should start an authentication flow allowing you to authenticate into GitHub.

This next step is more of quality of life improvement. By default Termux will open the home directory (~) when launched, but you will have trouble reaching this directory in the Android file system due to folder protections. If you want your code to be accessible to the Android file system (which you do if you are using a code editor) then it’s best to store it in the following location (git is a folder I created to store my code):
~/storage/shared/git

This can be a bit of a pain to cd into every time you open Termux, so a symlink can be created. Assuming that your in the home directory you can type the following command:
ln -s ~/storage/shared/git git

This will create a link to the folder in shared storage that is accesible from the home directory by typing cd git

Seeing in colour

This is another quality of life improvement. Like many terminals Termux on its own doesn’t do much for providing git information. You can install OhMyZsh into Termux to provide branch highlighting and other changes when working with branches. Luckily a lot of the process has been done for us and can be done using the following command:
sh -c "$(curl -fsSL https://github.com/Cabbagec/termux-ohmyzsh/raw/master/install.sh)"

Hugo

Hugo is a framework for building websites. It takes your directory structure and markdown files and turns them into static html. What this means is a simple and straightforward website generator that is very fast to load. The downside is there is a little bit of a learning curve (that I’m still learning!) but it is worth it for ease of use and flexibility. I won’t go into using or editing Hugo here as this is more about getting it up and running, but will talk more about the setup of this blog in Hugo in future posts.

Hugo can be installed and run in Termux. The great part about this is you can see and edit your website locally in Android. As previously from a Termux prompt ensure pkg is updated:
pkg upgrade

And then install Hugo:
pkg install hugo

It’s as simple as that. You should now be able to call hugo server from your git repository to serve your website, and see the results in Chrome by going to the specified URL. (You might get a build lock error in which case the flag –noBuildLock can be used).

Editing apps

Finally I spent a little time on editing apps. Thanks to the current state of Google search there are no end of lists claiming “The Top 10 Best Editing Apps On Android”. I went through a couple but found them to be either defunct or cloud only. I settled on Acode. There’s no markdown preview that I’ve found yet but it works well with markdown syntax highlighting. Another option is to isntall Visual Studio Code via Code Server. There are plenty of tutorials on this but it would involve using your Termux session.