Blogging from the terminal with doom emacs & hugo on a mac

I’ve been looking to make blogging from org-mode on my mac happen ever since I started using org-mode. Reason being is that while I love learning about all the new frameworks, what I really want is a stupid easy way to write then type a few commands and my writing appear on my site. Now that I’ve repeated the process a few times - installing, configuring, breaking, fixing, breaking again, uninstalling, reinstalling - the way I learn best - I’m happy to share the exact steps I took to get here. These are should be repeatable and simple steps using mostly defaults so there’s less stuff to worry about backing up in case you have to nuke the site from orbit.

First off, I’d like to thank Carl Flippin with this post - https://carlf.io/posts/blogging_with_org_and_hugo/ - who I randomly found online and also happened to work with in the past. So cool when that happens. Thanks Carl for getting me over some issues early on in my process! Hope you’re doing well.

Prerequisites

  • A Mac
  • A Github account (or gitlab, netlify, render, etc)
  • Some working knowledge of moving around Terminal
  • Optional - a domain name

Emacs Installation & Setup

These install steps assume a blank Mac. If you have Homebrew installed, please skip that step. If you have Emacs installed, you can skip that step, but ideally you’re running the latest version so consider upgrading. The Doom installation step/script intelligently checks for existing Emacs and Doom installs so it doesn’t accidentally write over your custom files.

Note: I don’t put the select/copy/paste buttons in my blog so that you have to exert at least a little effort and therefore maybe thought before blindly copy/pasting commands that do things like install or change system settings. Regular code seems fine in that regard. However, I also don’t think I should go as far as disabling copy/paste entirely. Don’t you hate that?

Install Homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Don’t take my word for it though, check on https://brew.sh/.

Install Emacs

This installs within the terminal…it is not a standalone app. The biggest issue I’m having with that right now is that the Terminal.app captures some of the key bindings before they get to emacs. If I find my way around that, I’ll post an update.

brew install emacs

Friend’s don’t let friends copy/paste install commands, check on https://formulae.brew.sh/formula/emacs

Note: I’ve read a lot - and tried a lot - of different emacs installation methods. There’s emacs+ and the cask version for homebrew. I prefer this approach. there’s also a benefit that you can get the following steps set up and remove this flavor of emacs, try the others, and ultimately if you want, like I did, just do another brew install emacs again and everything should be as it was. I’ve done this about 5-6 times and it’s worked every time.

Install Doom

git clone --depth 1 https://github.com/doomemacs/doomemacs ~/.emacs.d
~/.emacs.d/bin/doom install

Check yourself before you wreck yourself: https://github.com/doomemacs/doomemacs#install

Hugo for org mode

This is the one customization you’ll need to do in this otherwise basic default install. In your init.el file in ~/.doom.d/, please change the org under :lang to (org +hugo) and then run:

doom sync

And one last time, confirm here: https://github.com/doomemacs/doomemacs/blob/52bda5f

The process

Once all of this is set up, then there’s some further customization steps and the actual writing and publishing.

  1. Pick a theme for your blog: https://themes.gohugo.io/
  2. Create a repo on Github (or your favorite competitor)
    • Gitlab
    • Netlify
    • Render
  3. Add in this Github actions build and deployment config (or whatever approach makes sense including Netlify): https://gohugo.io/hosting-and-deployment/hosting-on-github/#build-hugo-with-github-action
  4. Make sure your host of choice is ready to receive your pushes and process things on the right branches. The links above should illustrate how to do that.
  5. Write in org-mode
    1. SPC-b-s to save
    2. SPC-m-e-H-H to publish to Hugo
  6. Test locally
    1. hugo server -D
    2. go to http://localhost:1313
  7. Commit
  8. PUSH & PUBLISH
  9. Celebrate!

====== fin ======

Related Posts

My working setup

Updated June, 2024

Here’s how I currently do my work, both personal and professional.

  • iPad
  • Mac
    • Terminal with Oh-my-zsh for terminal-ly good looks (and shortcuts)
    • Doom Emacs - I wrote about doom emacs for blogging
    • Roon - Can’t work without music!
    • Visual Studio - replaced TextMate and SublimeText and haven’t looked back; strange for me to say that for a Microsoft product (different than say GitHub, which was an acquisition)
    • 1Password - long-time user
    • Trello - Despite the Atlassian acquisition, this is still my go-to for just a general purpose throw it up and track it. Using the Assista bot for time tracking on tickets I drag into the Doing list - it helps a lot with billable work, but also helps me track where my play time goes.
    • yt-dlp - it’s a secret
    • CyberDuck - connect to anything for remote file access/management
    • Homebrew - I see no reason to leave this hardy package manager - it’s just worked under brutal conditions for years and years.
  • Home network
    • Fiber, it’s the only way to fly
    • Unifi network throughout house; wired (by hand, blood, dust, cobwebs, and pink spackle) and wireless
    • Pi-hole - remove all the craptasic stuff out there, network-wide
    • Tailscale - take my networks with me securely (recent addition so lots to learn)
  • SaaS
    • Cloudflare - it’s the only online service that I don’t have a fear of recommending. Yes, there might be some issues from the centralization of the decentralized web, but right now, that’s not a critical path issue.
    • Hugo - The most performant, flexible, and joyous web development platform. This site and my LLC and Synth company are built with it.

ChatGPT as source control

In my normal use of Chat GPT, I’ve started behaving as if it’s source control when I have code generated. It’s a place I can go back to a point in time if something broke.

It’s not robust, doesn’t have a GUI/CLI specifically for that purpose, is lightyears behind git, but regardless, I find myself using it that way.

Of course I still use and depend on git for anything serious, but it’s fun to noodle new world scenarios.

A privacy and security pledge

Update - <2022-10-18 Tue> - I just also found out about The Santa Clara Principles - it’s not exactly what I’m thinking about, but it’s interesting as a model and has input from the EFF, ACLU, and The Brennan Center for what it’s worth.

I’m thinking about building a piece of software…more than that actually. Been designing it for a while now and there are certain values I’m trying to bring to the project. Things to do with what I want and feel is right around privacy, data-ownership, security. Values that I want the software I buy and use to hold as well. It got me thinking that I’d like to sign some kind of pledge of user-goodwill on topics like these.