D'Arcy Norman, PhD

developing a custom hugo theme with claude

I’ve been using a customized theme based on the great Beautiful Hugo theme for Hugo for a few years now. It’s worked well, and I’d made a lot of adjustments to make it do what I wanted. But it never felt like “mine” and I’d always meant to take the time to build my own. So, Which was likely never going to happen, so a week and a half ago I thought I’d try building one with Claude:

I want to build a new theme for my Hugo powered website. I want it to be clean and modern, simple, have dark and light modes, hierarchical menus in a navigation bar, and clean typography. I don’t want to use any external resources if at all possible (so, only self-hosted fonts and libraries). Can you start building that?

πŸ€– - AI-Generated Content via Anthropic Claude 3.7

I’d be happy to help you build a clean, modern Hugo theme with the features you’re looking for. Let’s create a basic structure for your theme with the necessary templates and styles. I’ll focus on making it lightweight, responsive, and fully self-hosted as you requested.

themes/
└── cleanmodern/
    β”œβ”€β”€ archetypes/
    β”‚   └── default.md
    β”œβ”€β”€ assets/
    β”‚   β”œβ”€β”€ css/
    β”‚   β”‚   β”œβ”€β”€ style.css
    β”‚   β”‚   β”œβ”€β”€ dark.css
    β”‚   β”‚   └── light.css
    β”‚   β”œβ”€β”€ js/
    β”‚   β”‚   β”œβ”€β”€ theme-toggle.js
    β”‚   β”‚   └── menu.js
    β”‚   └── fonts/
    β”‚       β”œβ”€β”€ inter/
    β”‚       β”‚   β”œβ”€β”€ Inter-Regular.woff2
    β”‚       β”‚   β”œβ”€β”€ Inter-Bold.woff2
    β”‚       β”‚   └── Inter-Italic.woff2
    β”‚       └── font-face.css
    β”œβ”€β”€ layouts/
    β”‚   β”œβ”€β”€ _default/
    β”‚   β”‚   β”œβ”€β”€ baseof.html
    β”‚   β”‚   β”œβ”€β”€ list.html
    β”‚   β”‚   └── single.html
    β”‚   β”œβ”€β”€ partials/
    β”‚   β”‚   β”œβ”€β”€ header.html
    β”‚   β”‚   β”œβ”€β”€ footer.html
    β”‚   β”‚   β”œβ”€β”€ nav.html
    β”‚   β”‚   β”œβ”€β”€ meta.html
    β”‚   β”‚   └── toc.html
    β”‚   β”œβ”€β”€ index.html
    β”‚   └── 404.html
    β”œβ”€β”€ static/
    β”‚   └── images/
    β”‚       β”œβ”€β”€ favicon.ico
    β”‚       └── logo.svg
    β”œβ”€β”€ theme.toml
    β”œβ”€β”€ config.toml
    └── README.md

I’d made the mistake of forgetting to set the chat to “Extended” mode, which is somehow better for coding stuff. So this may have worked better in that mode, but even in normal mode it worked well. It generated a bunch of files as Artifacts, which I could download and put into the right locations in a new theme directory. Then I fired up Hugo in server mode to test it out. And it actually worked! It looked ok, and needed some adjustments, but that was just a simple back-and-forth with Claude:

I had it finish some of the additional files:

I need layouts in layouts/_default for “page.html” and “terms.html”

(it did, which I downloaded into the right directory)

Then I got some errors when viewing the site:

When I build the site, I get a “Page not found” message instead of the homepage, and I get these messages in the log:

WARNΒ  found no layout file for “html” for kind “home”: You should create a template file which matches Hugo Layouts Lookup Rules for this combination. WARNΒ  found no layout file for “html” for kind “taxonomy”: You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

πŸ€– - AI-Generated Content via Anthropic Claude 3.7

Those warnings indicate that Hugo is looking for specific layout templates that are missing. Let’s fix those issues by creating the required templates:

…

It created the files, I put them in the right spots, and different error messages and tweaks were required.

By this point, there were lots of different files with lots of different versions. It was kind of a mess to do in a chatbot:

Is it possible to download all of those files in a single .zip archive? Downloading each file individually, renaming them (they get downloaded with different names for some reason) and manually recreating the folder structure is tedious and error-prone.

πŸ€– - AI-Generated Content via Anthropic Claude 3.7

I understand that downloading and organizing each file individually would be tedious and error-prone. Unfortunately, I can’t directly create and provide a downloadable ZIP archive of all the files.

Yeah. It’d be handy if I could access files in a synced folder or something. Maybe WebDAV access to the chat?

A few improvements to add:

  • I have a page at /photos/ that displays posts with photos. I want that page to show the latest 20 photos, in a grid layout of css-resized thumbnails rather than full-size posts on the page.
  • The content page for single display looks good but it’s too wide - can the content part of the post be set in a bit horizontally so it doesn’t start right at the left edge?

πŸ€– - AI-Generated Content via Anthropic Claude 3.7

I’d be happy to make those improvements to your theme. Let’s start with creating a special layout for your photos page and then adjust the single post layout to have better horizontal spacing.

1. Creating a Photos Page Layout

First, let’s create a special layout for the photos page that will display a grid of thumbnails:

layouts/photos/list.html

Click to open code

Tap to open

Now, let’s add the CSS for the photo grid layout:

assets/css/style.css (Photos CSS Addition)

Click to open code

Tap to open

Now, let’s make sure your site recognizes the photos section by creating a specific archetype for it:

archetypes/photos.md

Click to open code

Tap to open

Let’s also create a sample content file for the photos section index:

content/photos/_index.md

Click to open code

Tap to open

Now, let’s update the single.html template to adjust the content width and add better horizontal spacing:

layouts/_default/single.html (Updated with Better Spacing)

Click to open code

Tap to open

I’ve implemented the improvements you requested:

  1. Photos Page with Thumbnail Grid:
    • Created a special layout atΒ layouts/photos/list.htmlΒ for your photos section
    • Designed a responsive grid layout that displays up to 20 recent photos
    • Each photo thumbnail is shown in a square format with a hover effect
    • Added an overlay with the photo title and date on hover
    • Includes responsive design for different screen sizes
  2. Improved Single Post Layout:
    • Added better horizontal spacing for the single post content
    • Set a maximum width of 800px and centered the content
    • Added padding (1.5rem on each side) to ensure content doesn’t touch the edges
    • Enhanced typography with better line height and spacing for better readability
    • Improved styling for images, blockquotes, and lists within content

To implement these changes:

  1. Add the new files to your theme:
    • layouts/photos/list.htmlΒ - The template for your photos grid
    • archetypes/photos.mdΒ - The archetype for creating new photo posts
  2. Update your existing CSS with the new styles I provided:
    • Add the new CSS code to yourΒ assets/css/style.cssΒ file
    • This includes both the photo grid styles and the improved single post styles
  3. Create the photos section in your content:
    • Create the directoryΒ content/photos/Β if it doesn’t exist
    • Add theΒ _index.mdΒ file with the content I provided
    • To add photos, create new content files in the photos directory with anΒ imageΒ parameter in the front matter

After implementing these changes, your photos page will display a nice grid of thumbnails, and your single post pages will have better horizontal spacing with a more readable width.

Would you like me to make any adjustments to these layouts or add any additional features?

I mean. That’s pretty thorough.

More back-and-forth tweaks, and I was pretty happy with the result.

screenshot of a custom home page. it looks like a web page.

screenshot of a custom photos page. it looks like a web page.

But it looks basically like “generic 2020s website”. It’s good enough, but bland.

So I started a new chat, added the style.css file from the custom theme, and gave a prompt (remembering to select “Extended mode”, whatever that does…):

I am working on a Hugo website and want to provide an alternate stylesheet. Here’s the current one - can you create a version of it that changes the display of the website to look like it is rendered in a terminal emulator? Green text on black background. Terminal-compatible font. Ideally, it should look like a modernized mainframe terminal from 1987.

πŸ€– - AI-Generated Content via Anthropic Claude 3.7

I’ll create a terminal-inspired stylesheet based on your current CSS. This will transform your Hugo website to look like a modernized mainframe terminal from 1987, complete with the classic green-on-black aesthetic.

Terminal Theme Stylesheet

Click to open code

Tap to open

I’ve created a terminal-inspired theme for your Hugo website that transforms it into a retro-style terminal interface from the late 1980s. Here are the key features:

Terminal Theme Highlights:

  1. Classic Terminal Color Scheme
    • Black background with phosphor green text
    • Different shades of green for various UI elements
    • Text has a subtle glow effect to mimic CRT monitors
  2. Terminal Typography
    • Monospace font family with VT323 as the primary choice
    • Uppercase headings with terminal-style prompts (>Β prefix)
    • Blinking cursor effect at the end of paragraphs
  3. Terminal Visual Elements
    • Scanline effect to simulate CRT monitor
    • Subtle screen flicker animation
    • Headings with pulsing glow effect
    • Navigation items styled with bracketsΒ [ ]
    • Terminal-style comment blocks for metadata
  4. Terminal-Style UI
    • Removed rounded corners for a more terminal-authentic look
    • Added terminal-style syntax to UI elements (>,Β #,Β /*,Β */, etc.)
    • Photos rendered with a green phosphor filter
    • Terminal-style borders and containers
  5. Responsive Design
    • Maintains all the responsive breakpoints from your original CSS
    • Mobile menu adjustments to match the terminal theme

How to Use This Theme:

  1. Save the CSS as a new file in your Hugo project (e.g.,Β terminal-theme.css)
  2. Link to it in your theme templates, either as an alternative theme or with a theme switcher

The stylesheet preserves all the functionality and structure of your original CSS while giving your website that authentic terminal aesthetic.

And. Dang. Some minor back-and-forth to clean up the CSS, but it’s a fully working theme that feels exactly like what I’ve wanted for years. It applies green phosphor tint to images (but I told it to add javascript so you can click any image to see the original colour version) (which, if you’re viewing this on the web instead of your RSS reader, scroll up and click on the first 2 screenshots to see them in full colour). Titles have blinking cursors. Amazing.

screenshot of a custom home page. ripped somehow out of a 1980s-era CRT terminal.

Comments powered by Talkyard.