Blog Post Writing
Review
In my previous post, I mentioned that my website allows me to write posts in org-mode which are then converted to HTML on deployment. I wanted to give some more information about that.
Org Intro
For those unfamiliar Org Mode is a package shipped with vanilla Emacs for managing Org files. Org files are a plain text format for structured documents. They can be used for tasks like outlining, notes, todo lists, project management, literate programming, and more. Some people put their whole life in Org files. While I don't go that far, I've often found it a good format for writing things down. Writing it is very similar to writing markdown, but much more fun with all the Emacs support available.
Hugo Support
For a comprehensive guide on how Hugo translates Org files to HTML, check out go-org for examples.
Specifics
Each Org file I create has some metadata at the top about my blog post. It has a title, date, summary, and whether the post is currently a draft. For example, this is the header for this summary.
#+title: Blog Post Writing #+date: 2025-06-17 #+draft: true #+summary: How blog posts are made.
Below the header is whatever Org syntax I want. I can easily have headings, paragraphs, ordered and unordered lists, links, code blocks, pictures, tables, and more.
Automation
To make things a little smoother, I can reduce the friction further by opening the right file and generating the metadata for each post. Emacs comes to the rescue and I can add a command to make a blog post easily.
(defun blog-post (title)
(interactive "MPost Title: ")
(let*
((date (format-time-string "%Y-%m-%d" (current-time)))
(slug (downcase (replace-regexp-in-string "[^[:alnum:]]" "-" title)))
(filename (file-name-concat
"~/src/personal-website/content/blog"
(file-name-with-extension slug "org"))))
(find-file filename)
(insert
"#+title: " title ?\n
"#+date: " date ?\n
"#+draft: true\n"
"#+summary: ")))
This code should not be hard to read even if you don't write Emacs lisp. Here's what it does.
- Interactively reads a post title as a string if an argument is not provided. "M" is a type code for a string and "Post Title: " is the prompt. No idea why "M".
- Get today's date in YYYY-mm-dd format.
- Convert the title to a slug that can appear in a URL.
- Generate the filename in my website git repo.
- Open the file.
- Insert the metadata block, leaving the point at the end for me to fill out the summary.