I currently use Hugo to generate the site content from markdown. The content is hosted by Netlify. The source for this site is on GitHub.
Generating site content
I want a simple tool that allows full control over the content I publish, and isn’t too difficult to maintain. Below are some more specifics, and how Hugo provides.
Must have
- easy to write (markdown)
- server generated syntax highlighting. See below for details.
- minimal (no) JavaScript. Small HTML + CSS.
- this depends on the Hugo theme you use - there are tiny themes out there, like xmin. I copied this into my repo to make my own tweaks.
- no invasive trackers like google analytics
- doesn’t look like a Wix/Squarespace site :)
- published content is fully customisable with Hugo themes
- An easy-to-navigate ‘current’ and ‘archives’ view
- again, this depends on the theme. My blog base page is simply a list of all my posts. That works for now!
- URLs that don’t need to change
- posts follow directory structure. I timestamp my posts, so the URLs shouldn’t ever need to change.
- RSS, or however news readers work
- Hugo automatically generates an RSS index.xml by default
- Hugo docs: RSS
- this actually took some work to get right, see details below
- easy to read on a phone, tablet and PC
Nice to have
- dark theme
- I use dark reader and Feedly
to read most sites, so pretty colours & formatting don’t bother me that much
- Update 2021-05-05: I just learned about the prefers-color-scheme css media query. This site is now dark if your OS/browser is set to dark!
- I use dark reader and Feedly
to read most sites, so pretty colours & formatting don’t bother me that much
- embedded search feature
- don’t need it for now. Looks easy enough: embedded search options
Some more details
Syntax highlighting
Syntax highlighting works out of the box with Hugo, and is done at build time, resulting in smaller page sizes than bundling a JavaScript syntax highlighter like highlight.js. For example, writing the following markdown results in the syntax snippet below:
```js
const main = () => { console.log("Hello world!"); }
```
const main = () => { console.log("Hello world!"); }
RSS
This took more effort than I expected. By default, Hugo generates an RSS feed for your home page, and each ‘section’ of your site, such as ~/blog, ~/about. I couldn’t figure out how to disable this, so I ended up deleting these files after generation in my ‘publish’ script. See this site’s source for more information.
Also, Hugo’s default RSS template only shows a summary of each article in the feed, which I find annoying when reading articles via my RSS aggregator. See RSS: Summary or full text? for more information about choosing between a summary or full text in your RSS feed.
Would it be easier to just write the HTML & CSS myself?
Probably not. Markdown is easier to read & edit, and Hugo generates HTML that I don’t need to tweak afterwards.
Other static site generators considered
Both of these are based on React, which put me off for a simple blog that could be hand-written in HTML. I also assumed Hugo would be faster, being written in go.
I’ve also briefly used Jekyll with GitHub Pages. It was a bit slow, and getting it working on GitHub took more effort than I had patience for. Also being a Windows user, the Ruby usage put me off.
Hosting
I chose Netlify due to its easy management of everything I could think of, and more. I could learn a lot by building my own infrastructure on AWS or another cloud provider, but that’s not the intention of this site.
Here’s what I want from hosting, and how Netlify provides.
Must have
- custom domain with automatic renewal
- HTTPS with automatic certificate renewal
- easy deployment process
- push to main, that’s it :)
- no invasive trackers like google analytics
Nice to have
- view/review before deployment
- Netlify has a feature that allows deploying branches to subdomains. See branch subdomains.
Some extra things that Netlify provides, that I hadn’t thought about:
- atomic deployments (no errors for users trying to view the page while content is being changed/uploaded)
- managed CDN
- domain registrations use Netlify as the WHOIS contact, keeping my personal contact details private from spammers. See domain registration.
Pushing updates to this site is as simple as pushing to my GitHub repo. Netlify watches my repo for updates and deploys them.
I configured my Netlify site to not do any build step. I simply build my site content locally with Hugo, include the published content in my git repo, and push to GitHub to publish new content. This removes complication from the publishing process. One complication I ran into was git submodules, which Hugo uses for themes. Netlify couldn’t clone my theme submodule. Instead of trying to figure that out, I just included my theme as regular files in my repo.
Other hosting options considered
Hugo-aware
All of these have HTTPS, deploy on push, and custom domain options. The drawback is that you rely on their support of Hugo. For a simple blog, pushing the rendered HTML + CSS from my dev machine seems good enough.
- AWS amplify
- Render
- deploy via GitHub, fully managed
- Netlify
- deploy via GitHub, fully managed
Others
- DigitalOcean app platform
- pro
- auto CDN, HTTPS
- deploy static content from GitHub
- con
- manual configuration for custom domains
- pro
- AWS S3
- lots of manual steps for HTTPS, CDN, DNS
- https://www.nearlyfreespeech.net/
- https://developers.cloudflare.com/pages/getting-started
- AWS amplify
References and further reading
- Creating a static home page in Hugo
- Do I need a CDN?
- faster load times around the world
- Feedly: optimise your RSS feed
- RSS: Summary or full text?