Aral Balkan

Mastodon icon RSS feed icon

Web development on a phone with Hugo and Termux

My S9+ phone on a wooden table with part of my Microsoft foldable bluetooth keyboard showing at the bottom of the photo. The S9+ is running Emacs with this blog post on the left side of the screen and the DuckDuckGo browser with the rendered version of the page on the right.

Web development in 2018: all you need is a phone.

Hugo is an excellent static site generator and website framework.

You can build a static web site using your phone by running Hugo on LineageOS under Termux.

Here’s how:

(The instructions below have been tested with LineageOS 15.1 and Termux 0.64.)

  1. Install Termux from the F-Droid catalogue

  2. Install Go (substitute .bashrc with .zshrc if you use zsh):

    # Install go.
    pkg install golang
    # Update your shell configuration.
    echo "export GOPATH=$HOME/go\nexport PATH=$PATH:$GOROOT/bin:$GOPATH/bin" >> ~/.bashrc
    # Reload your shell configuration.
    source ~/.bashrc
  3. Compile Hugo from source:1

    # Install Mage (a build tool for go).
    go get
    # Retrieve, compile, and install Hugo.
    go get -d
    cd ${GOPATH:-$HOME/go}/src/
    env DEPNOLOCK=1 mage vendor
    mage install

That’s it!

You should now have a working Hugo setup. Enjoy web development from your phone and, if you want an easy way to deploy from your phone and/or to join the peer web, check out my other posts on Web+2.

Written on my LineageOS phone using Termux, Emacs and Hugo. Deployed via rsync and available on the peer web at dat:// To view peer web sites, use Beaker Browser.

  1. The official Hugo compilation instructions hang under Termux at the mage vendor command. The instructions here differ from those by setting an environment variable that avoids the hang. ↩︎

  2. Web+ and Web+ on a phone ↩︎