New Blog Link to heading
I decided to move off of WordPress and move to a static blog. Most of the time I prefer writing things in Markdown, so moving to a solution where everything is natively in Markdown makes a lot of sense to me. Before settling on Hugo I looked at a few other options (including of course contemplating writing a generator in C#, but that would be a terrible case of bikeshedding).
Why Hugo? Link to heading
Hugo has a benefit over a lot of other static blog generators (like Jekyll or Gatsby or one of the others out there), namely:
- It’s mature enough where it can be trivially hosted via basically any service which can host static pages (I’m using CloudFlare pages)
- It has a wide variety of free themes available (no one wants to see what happens when I try to make a design)
- The hugo binary is both fast and space efficient (one of the biggest advantages Go has over .NET is still how small the binaries can be)
How it is setup Link to heading
Setup was pretty simple. Just follow the docs on the Hugo website to install Hugo:
- Install Hugo (
brew install hugo
if on a Mac) - Create a new Hugo project
hugo new site <your project name>
cd
into the directory made by the previous step- Open your text editor of choice in the directory (i.e.
code .
) - Find a theme (I’m using hugo-coder)
- Follow the steps to install the theme as a git submodule
- Edit the
hugo.toml
file to set things up. Reference the theme documentation to make sure you have everything necesssary - Run
hugo server -D
and make sure everything looks good - Add the blog into Github (other SCM solutions may or may not work depending on where you are hosting)
- In CloudFlare go to “Workers and Pages” > “Pages” > “Connect to Git”
- Add your repository to CloudFlare
- Set the build command to
hugo -b $CF_PAGES_URL
, the build output directory to/public
and set the production branch tomain
- Depending on your theme, you may need to set the
HUGO_VERSION
env var tov0.134.0+extended
- Deploy the site, wait for it finish.
- Go back to the site, and set the custom domain (assuming you have your domain already with CloudFlare)
Migrating old content Link to heading
I have a number of blog posts that were in the previous WordPress install, and I really didn’t want to lose them. Thankfully, someone wrote a fantastic little tool which can export a wordpress export.XML file to markdown (which Hugo consumes with minimal additional editing).
- Go to your old wordpress site and find the Export option
npx wordpress-export-to-markdown --input=export.xml --post-folders=false --save-attached-images=true --save-scraped-images=true
will pretty much do everything for you. The one big issue I did encounter was that images with the same file name will overwrite each other (i.e. if you have PostA and PostB that both have a different image named img1.jpg, whichever image is downloaded last wins).
First Impressions Link to heading
Overall I’m happy with my choice to migrate to Hugo so far (granted this is the first post I’ve written since the conversion). I also added a few things that are a bit more fresh like my about page or my now page which will give you a bit more information about who I am. I also re-did my resume with jsonresume.