Hugo + SHH - gulp = a new workflow

If you ready the post on Hugo + gulp = Chromebook awesomeness you’ll know that I’ve been adjusting my workflow to get Hugo to live reload on Chrome OS. While that solution worked okay, there were a few issues with it.

First off, the process required that a gulp task be setup to sync the files with the Termux. This isn’t a big deal, but as a project grows there’s more to sync, which causes the process to slow down. Additionally, it stores a duplicate of the files, which digs into the precious limited space on many Chromebooks.

Finally, what really drove me to a new solution is when I was trying to update a node package and couldn’t in the regular Chrome OS directory. So that lead me down the path to find a new workflow.  Among the solutions looked at was a very cool project called droppy which even has a built in text editor - more on this in a later post, as it was not the 100% solution that I was looking for.

Links to the other posts in the Hugo series

  1. Running Hugo on Chromebook
  2. Resetting My Chromebook Back to Stock
  3. Hugo + gulp = Chromebook awesomeness
  4. Serverless dynamic content with Hugo and JavaScript
  5. Adding search to Hugo with elasticlunr
  6. Hugo + SHH - gulp = a new workflow
  7. Hugo and droppy, Chromebook friends

The SSH solution

After hours of googling and smashing keys I came to the solution of using Termux to create a SSH drive. This allows the Termux file system to see the changes and all of the Chrome OS apps to also see the files. After patching the many posts together, I came up with a simple guide to do this.

To Setup initially:

Install the apps needed

  1. Install Termux
  2. Secure Shell App

Configure the applications

  1. Launch Termux
  2. Type termux-setup-storage
  3. Type ifconfig arc0 | awk '/inet /{print $2}' and notet the IP - mine was 100.115.92.2 and it just the IP address that Chrome OS has for Android
  4. Type whoami u0_a51

From Run an SSH server on your Android with Termux, which is really the only way I was able to get the SSH keys working

apt install openssh
sshd
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh
ssh-keygen

Then select the defaults for everything and when it’s complete copy the id_rsa with the following command cp ~/.ssh/id_rsa ~/storage/downloads/ to copy the key to your downloads folder.

Next, in the files Chrome app select Add new services and select Secure Shell App

Adding Termux as a file share

This will open up the following screen:

SSH to add the mount

Populate like the above image and select SFTP Mount, and boom your done. The write up Learning to Code on a Bone-Stock Chromebook really helped here. Note the -D 8400 the port can be what you like, but the -D needs to be there. I have noticed sometimes you’ll need to change the ‘8400’ port if the Secure Shell App hangs up on you, or even pkill sshd in Termux. You can name the connection anything you like, it’s what Chrome OS will mount as the Drive.

The final bits

Good news - that’s probably the last time you need to do all of that!   You can now simply type the following in Termux now and on reboot.

  • Open Termux
  • Type sshd (if your coming from the above then you can skip this)
  • Type export GOPATH=$HOME/go;
  • Type export PATH=$PATH:$GOPATH/bin;
  • cd to your directory
  • Type hugo server --bind="0.0.0.0" --baseURL="http://100.115.92.2" -F -D - I use the -F and -D flags for building the future and drafts.
  • Boom Hugo is running without any fancy scripts doing live reload!

One thing that I have noticed is that you may notice some weird issues with Termux after a long nap, but aside from that no issues!   Generally, dismount the SSH drive before closing to mitigate the issue. I have tried the Aquire wake Lock option for Termux, but it does not seem to resolve the issue.

Reference Information

The following post are what helped me get through this little project

Overall

This solution seems to be a good working solution for me at this time. There are times such as writing posts where I only use droppy as it take zero time to run it, but for heavier tasks this works great. I’ll be sure follow up this post with a write up on droppy just to bridge the gap because if all you need is a simple text editor it’s hands down the winner.