Blasts from the past

To save you the trouble, I revisit previous posts in search of useful info.

2022-10-14

As I noted a few days ago in “Tying up some recent loose ends,” I labor under no illusions that you good folks out there are going to watch this site like a hawk for updates to previously posted content. In similar fashion, I know that only some of what’s gone here before will get viewed at all.

Thus, if a newer visitor is to know about the older content, and particularly if such a visitor doesn’t luck onto the exact combination of magic words that one’s chosen search engine wants to see before providing a link to one of my posts, it behooves me to revisit some of the (I hope) helpful nuggets I’ve put here before.

That’s the purpose of this post.

As my regulars know, I write often about website development in general and static site generators (SSGs) in particular, and that will be obvious as you proceed.

For each item shown, I link to relevant posts, ordered chronologically by their original publication dates. Incidentally, what appears below may in fact have newer and/or additional information not included in any post listed with the item.


An SSG for your site

If you need to pick an SSG for maintaining your personal blog, my suggestion remains what it long has been: a “pick-’em” between Eleventy and Hugo. How can you choose between them? After all, both produce equally fast websites, all other things being equal, so visitors’ perceived performance is also a “pick-’em.” From there, I’d break it down this way:

  • If you’re really into JavaScript (or want to be), go with Eleventy. You’ll be much more comfortable there.
  • If you want the greatest flexibility in templating, Eleventy is a no-brainer choice.
  • If you want maximum speed in development mode, go with the staggeringly fast Hugo. Be prepared to get comfortable with its wonky templating, however.
  • If you don’t want to deal with plugins and dependencies, go with Hugo. Eleventy is a combination — albeit an expertly assembled/maintained combination — of Node.js packages, while Hugo is a single binary with “batteries included.”
  • If you want to add features of your own choosing, go with Eleventy. This is where the Node.js universe has the advantage if you’re willing to deal with all those added packages. (Hugo isn’t nearly as extensible but, precisely for that reason, also is less brittle.)
  • If your site has, or is going to have, a lot of content — I’m talking thousands of pages or more — go with Hugo. Although Eleventy can be used for mammoth sites, Hugo’s sheer power makes them less onerous to manage, especially in dev mode.1
  • If your site is going to have multi-language content, go with Hugo, which has built-in support for that.

What about the oft-mentioned Astro? Although I retain very good feelings about Astro and the outstanding people behind it, I’ve personally found developing in Astro can still be annoyingly slow on a site with more than thirty or forty MDX files. However, if yours is smaller than that and likely to stay that way for a while, you may find the Node.js-based Astro your cup of tea, doubly so if you’re at least somewhat familiar with coding for tools such as Next.js.

As for Gatsby, the only other SSG I’ve ever used to manage this site, you can do so much better. Save yourself the trouble.

(I advise newcomers to this site that the unintentional irony within the first few titles comes from my infamous 2019 “Dance” among various SSGs.)

Jamstack-based website hosting

Getting your SSG-powered site actually on the web is best done through a Jamstack-savvy hosting vendor, where you can automatically build your site on each change you push to your online Git repository. Each such vendor puts your site on a content delivery network (CDN), ensuring your site’s content is “closer” (and thus delivered more quickly) to your visitors, regardless of their locations.

The hosting vendor I’ve used for over a year now, and which I recommend, is Cloudflare Pages, which provides all the advantages of Jamstack-savvy hosting combined with the most extensive CDN in the field, especially given that it’s on the free tier. I’ve also used the free tiers of Netlify, Vercel, Render, and Firebase — as well as a Cloudflare Workers site, the predecessor of Cloudflare Pages.

Styling your site

Over much if not most of this site’s existence, I’ve styled it with Sass, although I’ve also used (and admired the development behind) the hugely popular Tailwind CSS. There even was a time when I used only more-or-less basic CSS but with the PostCSS preprocessor, but I thought better of it later.

I prefer Sass because it comes with everything I need for styling, so I don’t have to fuss with additional items and their potential breaking changes — somewhat similar to that whole “batteries included” thing with Hugo that I mentioned earlier. However, where Hugo is concerned, using the current version of either Sass or Tailwind CSS can be problematic; so I’ve spent some time explaining how to get around those issues unless/until there are more official solutions.

Web fonts

If you choose to use web fonts, don’t use any served by Google Fonts, so as to avoid the tracking code that accompanies them from there. Instead, download their files and serve them from your site.

I also suggest using variable versions of web fonts, where possible, because they provide more styling choices but with smaller files and smaller numbers of files. That’s even truer if you properly subset them to eliminate all but the characters you truly need.

And, hey: there’s absolutely nothing wrong with using the system fonts stack — relying on the fonts built into your visitors’ operating systems and devices — especially in this era when those fonts, and the devices displaying them, do so much better than in the past.

Static embeds

It can enhance your site if you embed things like YouTube videos and tweets, but be careful: using the providers’ default methods for such embeds will inflict a ton of sneaky tracking code on your visitors. The better way is to embed the content fully statically, providing virtually the same content and appearance but without the tracking.

Note: Due to changes in the status and/or availability of one or more Twitter APIs, perhaps due to the many corporate changes at Twitter itself following its purchase by Elon Musk, I have deprecated several posts, or sections thereof, concerning the fully static embedding of tweets within one’s website. However, all the relevant URLs still work and, for each, provides a link for viewing the now-deprecated content.

What’s wrong with WordPress?

Those website maintainers who are familiar, even comfortable, with the WordPress content management system (CMS) can tend to get annoyed when we SSG users try to pull them over here and away from The Dark Side. Why, they ask, would I ever want to leave WordPress for an SSG?

It all comes down to performance and security.

  1. A WordPress site is dynamici.e., every visit generates a page on-the-fly from a database — and that makes it slower than a static site, which is just a set of pre-built, ready-to-view static files.
  2. The database also makes a WordPress site less secure than an SSG-built site. Bad actors love nothing better than to crack a database that isn’t sufficiently protected (“hardened”), which unfortunately describes many WordPress sites’ databases and the platforms on which they exist.
  3. To gain additional features, nearly every WordPress site uses plugins, sometimes a lot of them, and every additional plugin (a.) further slows down the dynamic page-building process and (b.) constitutes another potential security vulnerability, especially since many plugins are poorly coded and/or maintained.

However . . . if one still prefers WordPress just for its CMS capabilities, at least there are ways to make WordPress serve as an SSG2.


  1. Hugo’s chief maintainer, Bjørn Erik Pedersen, has been hinting in recent months at a future update that will allow managing a site with “millions” of pages. While I doubt that anyone reading this needs that kind of power, it never hurts to have plenty of overhead room, so to speak. ↩︎

  2. For example, see “Getting Started with WordPress Static Site Generators.” ↩︎

Next:

Previous: