Testing Micro.blog theme changes locally on macOS
Developers commonly get hung up on setting up the perfect blog before actually blogging. I avoided that temptation by using Micro.blog, which makes it really easy to get started and not be fussy with custom code.
That said, I now want to make some improvements to the default theme (Sumo) that I use on my blogs.
Here’s how I got a fork of the theme running locally with the content from one of my blogs.
First, shout-out to Stephen Bowling for posting his approach to running Hugo locally.
I downloaded the hugo_0.117.0_darwin-universal.tar.gz
release of Hugo from GitHub: https://github.com/gohugoio/hugo/releases/tag/v0.117.0
After moving the hugo
binary to /usr/local/bin/
, I ran this command to bypass the macOS security gatekeeper:
sudo xattr -d com.apple.quarantine /usr/local/bin/hugo
Next, I went into my Micro.blog account and clicked on Posts, then in the ··· menu, I clicked Export. From there, I downloaded the “Export theme and Markdown (.zip) — to use in Hugo.” I opened the ZIP file and renamed it web.chasen.dev
.
In that folder, I deleted the layouts/
folder (so my theme changes could apply).
In that folder, I created a themes/
folder. More on that in a moment.
I have Micro.blog archive my content, so I downloaded the uploads
folder from my archive and copied it into the static/
folder.
I said at the beginning that I wanted to make changes to the Sumo-Theme
. I forked that repo in GitHub and then cloned it into the themes
folder I made a moment ago.
I also cloned theme-blank
into that folder, so now the themes
folder has those two repos inside it. This is required because the “blank” theme provides some partials that are required for building your site.
Now we can get cooking–to run Hugo and have it use the two repos we cloned, I run this command in my web.chasen.dev
folder:
hugo server --themesDir=themes --theme=Sumo-Theme,theme-blank -D
Your site should build and be available at http://localhost:1313/
Now, I can make changes to Sumo-Theme
and, with the Hugo server running, my site is rebuilt and I can preview the changes locally. Success!