Well, it’s been a while. The last post here was in 2016, which apparently means I took a ten year break from blogging. Oops. The blog was still sitting here, but the software behind it hadn’t exactly gotten any younger. I figured it was time to dust it off & make it a little easier to actually use again.
Naturally, I started by rebuilding the thing instead of writing a post. Some habits haven’t changed. :)
Why?
Back in 2014, I wrote about moving from Wordpress to Octopress. I liked having plain text files, generating a static site, & not having to maintain a database just to serve some blog posts. I still like that approach.
Octopress is no longer maintained, with v3 being promised since 2015. The blog was already hosted on Cloudflare, but I also didn’t have a proper deployment workflow tied to the source in GitHub. If I was going to spend some time on this, I wanted to fix both parts.
I settled on Hugo with the PaperMod theme. I wanted something fairly simple that looked good with technical posts, code blocks, & screenshots. I did briefly try a couple of other themes like Coder and Nightfall before coming back to PaperMod. Picking a theme continues to be something I take too much time doing
Here’s what actually changed:
| Part | Before | Now |
|---|---|---|
| Site generator | Octopress & its Ruby dependencies | Hugo |
| Theme | The old Octopress layout | PaperMod, following the browser’s light/dark setting |
| Publishing | No GitHub-connected deploy workflow | Merge to main, Cloudflare builds & deploys |
| Checking changes | No PR build checks | GitHub Actions build & Cloudflare branch preview |
| Posts & images | A mix of Markdown, old tags, & HTML | Markdown, highlighted code, & clickable image previews |
The old URLs & /atom.xml feed stayed put. Those weren’t things I wanted to reinvent.
Moving the Content
I used ChatGPT against the local codebase to work through the conversion, config changes, & deployment setup. The useful part was being able to point it at the existing files, make a specific change, then build the site and inspect the result. There was plenty to check beyond whether Hugo could parse the Markdown.
The imported posts mostly stayed as individual files in content/posts/. New posts use a directory containing index.md and any images for that post. The important parts of an imported post’s front matter look like this:
---
title: Netflix Subtitles
date: '2010-09-27T00:00:00-04:00'
url: /2010/09/27/netflix-subtitles/
slug: netflix-subtitles
---Keeping the original date, timezone, & explicit url avoids changing an old post’s address just because its filename or the site generator changed. For new posts, the default URL pattern is configured in hugo.toml:
[permalinks.page]
posts = '/:year/:month/:day/:slug/'There are also older URL variants, including paths with a /blog/ prefix. Those go in static/_redirects, which Hugo copies into the build output for Cloudflare to use:
/blog/2010/09/27/netflix-subtitles/ /2010/09/27/netflix-subtitles/ 301I kept /atom.xml as the feed URL too. That means defining an Atom output format & keeping the feed templates, rather than silently switching everyone over to a different endpoint. The homepage also generates JSON for PaperMod’s search page:
[outputFormats.atom]
mediaType = 'application/atom+xml'
baseName = 'atom'
isPlainText = true
rel = 'alternate'
[outputs]
home = ['html', 'atom', 'json']Cleaning Up the Markup
Some posts still had Wordpress [sourcecode] tags, while others had HTML mixed into the Markdown. Apparently my old Wordpress markup had survived more than one migration. Heh.
For example, the old Wordpress code markup looked like this:
[sourcecode language="bash"]
cd subtitles
chmod +x srt2dfxp.py
[/sourcecode]That got replaced with a Markdown fenced code block, with bash after the opening backticks. Same commands, but Hugo can actually highlight them:
cd subtitles
chmod +x srt2dfxp.pyThat example is from the old Netflix subtitles post. There were 28 samples across nine posts that needed cleaning up. Shell commands use bash, config examples can use ini, & command output uses text. Highlighting a dump of terminal output as if it were all shell code doesn’t really help anyone.
The syntax highlighting settings are explicit:
[markup.highlight]
lineNos = false
guessSyntax = false
noClasses = falseThat uses CSS classes for the highlighting & leaves the language choice to the code fence. A custom code-block render hook handles optional captions separately, so a filename or label doesn’t become part of the code you copy.
The imported posts also contain hand-written HTML, so Goldmark’s unsafe rendering option is enabled for this archive. The name sounds a bit alarming, but here it allows the existing HTML to render. This is my own content in git, not a form accepting arbitrary HTML from visitors.
Images had a similar compatibility issue. Markdown images go through a Hugo render hook, which can resize large page-bundle images & retain the original URL for the lightbox. Old HTML <img> tags bypass that hook. The lightbox therefore finds images in the rendered post, including ones wrapped in a link to an image file. For those, the linked URL is the full-size source. Links to other pages keep their normal behavior.
That was one of the places where reviewing the generated HTML mattered. A successful build doesn’t tell you whether clicking an old screenshot opens the right image.
Deploying It
The deployment side is much better now. The source lives in GitHub, & changes go through a pull request. GitHub Actions builds the site with Hugo and checks that important output files, feeds, & redirects are present.
Cloudflare also builds the branch & gives me a preview URL. I can check the changes there before merging, then merging into main triggers the production build for churnd.net. No manually copying the generated site around.
One clarification on the Cloudflare naming: I started out talking about this as a Workers deployment, but the setup we’re using is Cloudflare Pages, under the Workers & Pages section. Pages handles the GitHub builds, preview deployments, & production site.
The workflow looks like this:
The PR workflow runs on pull requests targeting main. It installs Hugo 0.170.0 from a release archive & verifies the archive’s SHA-256 before running it. Pinning the version means CI & Cloudflare are building with the same generator.
After the build, it runs a few smoke checks. This is the output verification from the workflow:
for path in index.html 404.html atom.xml index.json search/index.html \
2007/04/13/apple-remote-desktop-glitch/index.html _redirects; do
if [[ ! -s "dist/$path" ]]; then
printf 'Missing or empty build output: dist/%s\n' "$path" >&2
exit 1
fi
done
cmp static/_redirects dist/_redirectsThat catches a missing feed, search index, or archived page even if the build itself succeeds. The cmp checks that the deployed redirects match the source file. It doesn’t validate every link or tell me whether a screenshot looks right, which is where the preview comes in.
GitHub Actions & Cloudflare build independently. Actions provides the CI result; Cloudflare’s GitHub integration creates the preview and deploys production. The Actions job doesn’t upload dist/ to Cloudflare, & the generated directory stays out of git. I’m the only person working on this, so the checks and preview are useful even without a second person approving every PR.
One thing that caught me was the preview initially linking back to the production site. The homepage looked fine, but clicking a post took me to churnd.net. Setting Hugo’s base URL to the Cloudflare preview URL for branch builds fixed that. A preview isn’t particularly useful if you leave it as soon as you click something.
Here’s the build logic Cloudflare uses:
if [ "$CF_PAGES_BRANCH" = "main" ]; then
hugo build --minify --cleanDestinationDir
else
hugo build --minify --cleanDestinationDir --baseURL "$CF_PAGES_URL"
fiFor production, Hugo uses https://churnd.net/ from the site config. For a preview, CF_PAGES_URL supplies the deployment’s origin so generated links stay inside that preview.
The relevant Pages settings are:
| Setting | Value |
|---|---|
| Production branch | main |
| Build output directory | dist |
| Hugo config | publishDir = 'dist' |
| Production & preview environment | HUGO_VERSION=0.170.0 |
--minify reduces the generated output, & --cleanDestinationDir removes stale files from the destination. Neither changes the source posts. Also, if pasting that conditional into a single-line build command field, keep the semicolons between commands. Found that one out the fun way:
if [ "$CF_PAGES_BRANCH" = "main" ]; then hugo build --minify --cleanDestinationDir; else hugo build --minify --cleanDestinationDir --baseURL "$CF_PAGES_URL"; fiWriting Again
Creating a new post is pretty straightforward now:
hugo new content posts/my-next-post/index.md --kind post
hugo serverThat gives me a post in content/posts/my-next-post/index.md. I can work on a branch & preview it locally before pushing anything. Images can live beside that file & be referenced directly:
Then edit the Markdown & see the changes locally. Push a branch when it’s ready, check the Cloudflare preview, & merge to publish. That’s a workflow I’m much more likely to keep using.
Now What?
I’m pretty happy with how it turned out. ChatGPT was useful for getting through the migration & all the little fixes that went with it. I still needed to look at the results and decide what I liked, but it made a project I’d been putting off a lot easier to work through.
Of course, rebuilding the blog was the easy excuse. Now I actually have to write something for it. Hopefully the next post won’t take another ten years.
By the way, I also used ChatGPT to create this post. I wanted to see how well it could mimic my writing style based on my older posts. It turned out ok. Kinda summarized our back & forth chat dialog a bit.
ChatGPT definitely helped me cut down on the effort of migrating my neglected blog to something supported, as well as incorporating it into a proper pipeline. I really like hosting it on Cloudflare Pages.
I really don’t have time to write that much at this point in my life. Being a father of two teenage boys takes up all of my time. Who knows, maybe AI will help me keep the time investment lower going forward and it gives me a chance to get familiar with how to effectively use AI tools.