11 Dec 2021 by Simon Greaves
I run this static content website on Jekyll from files that are stored on GitHub.
To edit posts or add new content I would normally run a dev copy of the site locally on my laptop with Jekyll installed and modify it with Visual Studio Code then upload the changes to the live site on GitHub using git command line tools.
This works well except for those times I am not sat in front of my laptop, like now where I am sat on my iPad writing this. I wanted a solution where it could be hosted at home somewhere and then access it from mulitple locations and devices. My first thought was a VM (obviously, I am a VMware nerd after all!). This is ok if you don’t mind running a server 24/7 to host the VM, but I wanted something less power (and money) hungry, like my Raspberry Pi I use to run my home network tools, which uses a tiny amount of power and runs exceptionally quitely.
There are a few different blog posts out there with guidance on how to do this, but I wasn’t able to easily find one that was recent and with information that worked for my deployment. My Pi is a Raspberry Pi 4 with a default out of the box Raspberry Pi OS GUI installed, and a bunch of other software like Office applications, Scratch, browser and a few others. It also includes some of the prerequiste software like Ruby, however my version of Ruby didn’t work with the guides, and when I updated to a new version I ran into challenges as well, so this is what I did to successfully install and run my static site on Jekyll and then publish to GitHub, for your enjoyment!
First things first, check your version and if you are on an old version, we will update it to v3.x a bit later on.
Find out where its installed.
Check you have
make installed. These are required to run Jekyll.
gem -v gcc -v g++ -v make -v
Make a directory to store your static content website.
Go into the directory.
Prepare your bashrc variables for the upcoming installs.
echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc
Prepare the website directory with your existing static content site by cloning the remote public site to your local website directory.
git clone https://github.com/USERNAME/blog
Initialize the local repository.
Add the remote origin copy, which in my instance is in my master fork on GitHub.
git remote add origin https://github.com/USERNAME/blog
Verify its set correctly.
Pull the origin copy, just to make sure you have a synchronous copy of what’s on GitHub.
git pull origin master
Verify status again.
Now’s the time to update Ruby to v3.x.
Add the script to install the latest Ruby instance.
Run the install script (This takes a little while to install).
Reload the bashrc.
Verify the installed Ruby version, checking its now updated.
Install bundler using Gem
gem install bundler
If the install fails, update it first then install.
Update the bundle
Finally serve the Jekyll site. Note: If you want to access it from a remote session, like an iPad or Phone browser, specify the
--host IP_ADDPRESS variable at the end.
bundle exec jekyll serve --host 192.168.2.61
Now you have the site up and running you can use the Git command line tools to upload updated content.
git status git add -A git status git commit -m "New Comments on why updated or added" git status git push origin master git status
Comments are closed for this post.