More on this Blog

3 minute read

Friday night and by chance I thought why don’t I start writing my blog on my other mac. It is a smaller 12 inch macbook and it seems like a nice fit for writing. Once I started, however, I found myself a couple of hours in and it still wasn’t working. I was tired and figured I could work it out the next morning. After another hour or so of wrangling in the morning and it was done.

More specifically, I use a serverless cms called jekyll to write this blog. Per my previous post on this subject, I then sync it up to aws s3 and alas I have a fairly cheap website. I currently use a macbook pro to do this. The goal was to get all of the settings and data inluding posts from the macbook pro to the macbook. Both are running MacOS Monterey. The process that worked for me is as follows

Jekyll relies on ruby 2.5+, rubygems, gcc, and make. All of this is already preinstalled with MacOS. However, to manage Ruby I use RVM, which is a Ruby Version Manager. It is useful for quickly changing ruby versions and without it this project would have taken longer.

To install rvm requires running gpg which is installed via homebrew. This wasn’t installed. See instructions here for installing homebrew. During installation I stepped away for awhile and my laptop went to sleep during the installation and it failed. I reinstalled but the taps were empty of repositories everytime I ran brew install no matter the program to install. The fix was as follows:

# Fix Homebrew installation 
brew doctor
rm -rf "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core"
brew tap homebrew/core

To install RVM requires GPG. GPG or GnuPG allows you to encrypt and sign your data. To install this run:

# Install GnuPG
brew install gpg2

Once rvm was installed I could install and run any version of ruby necessary. Initially I installed version 2.7.5 as it is more recent but I soon found out this was likely the cause of some of the issues I ran into. I suspect using 2.6.9, since it is not a branch change, may not have issues but I did not test. I changed to match the version on my macbook pro which is 2.6.1.

# Sets rvm to autoload at shell start
source $(rvm 2.6.1 do rvm env --path)
# Install ruby 2.6.1. Could be any version
rvm install 2.6.1
# Sets the default version to 2.6.1
rvm --default use 2.6.1

After rvm is installed and 2.6.1 is set as the default version of ruby then Jekyll can be installed and will reference this version of ruby. Run the following command

# Install Jekyll
gem install bundler jekyll

Instead of running jekyll new to create a new blog I copied the entire blog folder from my other laptop. In addition to containing all of the posts, etc…, it also has the Gemfile with the necessary gems to install. The gems to bundle are as follows.

gem "minimal-mistakes-jekyll"
gem "jekyll-include-cache"
gem "jekyll-archives"
gem 'jekyll-sitemap'

To install the necessary gems change directory into the blog and run the following command. The correct versions will automatically get installed.

# Install the gems specified by the Gemfile
bundle install

When using Jekyll, the look and functionality is largely controlled via the use of Themes. I use a theme called Minimal Mistakes. This theme also not only controls the layout but also is where the assets/images are contained. It was necessary to copy the Minimal Mistakes folder from my other laptop in whole to my new laptop. I used a usb drive to manage. Run the following commands changing the name of the usb drive to that which are using.

cd ~/.rvm/gems/ruby-2.6.1/gems/minimal-mistakes-jekyll-4.15.2
cp -R /Volumes/MyUSB/minimal-mistakes-jekyll-4.15.2/ minimal-mistakes-jekyll-4.15.2

Now once all of this is completed navigate to the blog folder and delete the _site directory. Run the following command to rebuild and run your blog locally

# Update and run the blog
bundle exec jekyll serve

You can now browse to http://localhost:4000 to view your blog.

Once this is complete the final step is to install the aws cli, setup a user with an Access Key ID and Secret Access Key. Run aws configure to add a profile for this user and utilize the user’s credentials when run the aws commands. To publish any new posts run the following command.

# Publish new posts
aws s3 sync _site s3://yourwebsite.com

Finally, since I want to be able to create posts from either laptop I need a way to ensure any posts/drafts written on one are synced to the other. For now, I will just manually copy to my iCloud storage but maybe use rsync or something like that at some point.

Alas, this post was published on my macbook.