Since entering the idea of using a static site generator for blogging, and developing a website, I ran into a challenge. Auto updates. It’s certain I approach static from a CMS persepective. After all it’s been many many years that I’ve been deep into Wordpress as a solution for all websites.
The problem I faced in my mind, was getting Jekyll to always be watching and then regenerate a website when a change is made. I know traditionally Jekyll is hosted or connected to Git but I wanted to do it without, to prove it can be done. The restriction I was finding is after writing a post such as this one, I would have to ssh into my server and then run a command I created as an alias in my bashrc. Although clunky and not streamlined it works. To automate it, I tried things such as cron jobs, but it wasn’t quite the solution.
Then a lil nugget of info came my way, it mentioned “screen”. I read, I researched, and tried it (foolishly on this server live). It worked! I can now run ‘jekyll serve’ as a “background” process, it will regnerate anytime it detects a change on my site, and I worked past my pain point of having to leave a terminal window open all the time to get this result.
What is Screen?
Consider it like multiple desktops on a gui. Screen allows you to run multiple terminal instances, and switch between them.
According to man pages on screen..
Screen is a full-screen window manager that multiplexes a physical terminal >between several processes (typically interactive shells). Each virtual >terminal provides the functions of a DEC VT100 terminal and, in addition, >several control functions from the ISO 6429 (ECMA 48, ANSI X3.64) and ISO >2022 standards (e.g. insert/delete line and support for multiple character >sets).
The best part of screen, which got me most excited is you can detach from the particular “screen” and it will still run the processes happening within it. And even more thrilling, you can exit your terminal window and that process will keep going till you login, open that screen and stop it.
What does that mean for me? Well simple, I can run ‘jekyll serve’ in a screen, then close it and jekyll is now constantly monitoring for changes and will rebuild the site if changes occur.
If you want to jump into Screen, here’s a couple resoures you can learn from
So there you have it, problem solved. Now I can move onto my next challenge to learn. In wordpress I have my blog set so it auto posts to social media when a new post is made. I have a feeling the solution will lie within RSS and IFTT. But I’ll explore that later.
For now time to crack a beer and celebrate this victory.