GNU Terry Pratchett With Netlify and Hugo

Terry Pratchett is my favourite author. It’s not even close. His wit and wisdom shaped about as much of my worldview as my own parents.

He died in 2015, and it was awful. In the global trash fire of 2020, I’ve been re-reading a lot of his books for comfort, and it reminded me of this little endeavour.

There is a project, GNU Terry Pratchett, to keep his name alive in the internet, based on an idea from one of his books. His name is placed into the headers of a website - little bits of metadata that sites transmit to tell your browser how to deal with their contents - and transmitted with every request to that site’s server. In this way, his name will ping-pong around the internet forever.

If you’re interested in taking part, I recommend checking out the project site for details on how you can include the header in a bunch of different types of sites. You can also install some browser extensions that allow you to detect the header on other people’s sites when they’ve included it. It’s delightful to see it light up in places you weren’t expecting it.

Netlify and Hugo

This site is built with Hugo and hosted on Netlify. Netlify has a couple fairly easy ways to customise your site headers - check out their docs here. The most direct way I found with Hugo is to drop a file just named _headers in my static folder (and I imagine there’ll be similarities with other static site generators). Yes, the underscore at the beginning is important, and no it’s not got a file extension. On build, Netlify moves this extensionless file up to the publish directory, and it becomes the headers file for your site.

You can edit this extensionless file in any plain text editor. Within this _headers file then, just enter the following:

/*
    X-Clacks-Overhead: GNU Terry Pratchett

The /* means ‘everything within root’, so this will apply to every page on your site. Then, you can just declare the custom header. Don’t worry, it doesn’t actually do anything except send the name. Browser’s will just ignore it. As proof - it’s activated on this site. Even if you don’t have the browser extensions installed, you can probably see it in your browser’s development tools, if you go looking under the Network tab.

Anyway. Here’s a nice Terry quote to finish this post:

β€œIt’s still magic even if you know how it’s done.”

GNU Terry Pratchett.

πŸ“Ž Tags:

πŸ“‚ Recent posts in Blog: