Very meta: site updates

Published 2024-12-18

tag(s): #meta #blogging #emacs

I spent a bit of time making some site-wide updates. This was motivated by this post by Kev Quirk. I figured it would be nice to put a link in each post like he suggests, instead of only displaying my email address in the main page.

Usually when I want to contact an author, I navigate to their contact page if there isn't a link in the post itself, no big deal. But making it a thing directly in the post doesn't cost me anything, and I guess shows that I have an interest in engaging in conversation.

As a true Emacser, this led to a bit of yak shaving and some other updates...[1]
And also led to some reflecting about how I write my posts and how sustainable my homegrown system is.
Fair warning, this post will be the right mix of technical and "philosophical" (or, maybe, meta) to repel most audiences equally.[2]

Change 1: Consistent CSS

When I started the site, I made the decision that pages should be self contained. I am not even sure why I wanted that, but I still hold that principle.

One effect of this per-page flexibility was that then I could use different CSS for "pic posts" and "regular text" posts. Which I did. But then text posts started including pictures, so the img styling made its way into a few posts. I considered adding it to the regular text template.

Today I decided to create a single style section that I apply to ALL the posts. I will in a later section detail exactly of how I did it. But of course it involves using *gasp* Emacs! And how awesome the editor is.

Change 2: Simplified templates

I have three post templates: text, picture, and text in Spanish (soon™️ I will write my first post in Spanish...). One of the important aspects of the templates was having sample mark up of how to do common tasks, like formatting text and adding headings. The other one is that my "publishing tools" rely on certain text markers to replace with title, date, etc. when I want to start a new post.

Since starting the blog, I became more acquainted with mhtml-mode, Emacs' HTML-authoring mode. So I don't need all the sample formatting markup anymore: I use the mode's bindings to insert tags or surround text with them. I only need reminders on how to format code blocks, and how to write citations. Even footnotes are gone now as I have a special command for them.
So today I remove a lot of these samples from the templates, to make them simpler and smaller. Less to remove when I start or proof read a post.

Change 3: reply by email links

Finally I got to the change that started it all, I added at the bottom of each post a "share your thoughts/enviarme un comentario" link.
This required two things: updating the code to create a new post, and revisiting older posts to add the link.
The first change was simpler, I added a $subject marker to the templates, and the "new post" command includes this in the values it replaces when I start writing one, along with $title, $date and others. The title text is URL encoded.

Mass-editing text - Emacs keyboard macros

Of course I have to extol Emacs' virtues somewhere in the post 😏 At different moments I modified all posts in one go, using different approaches.
In one instance, this was a simple "replace some text in all these files", for which I used Dired and dired-do-find-regexp-and-replace[3].

But a couple more involved changes required multiple steps. For example adding email links: copy the post title, add the link to the email at the bottom of the post, and replace the encoded title in the subject section of the link.
Writing custom code for this sounds involved, luckily, Emacs makes this very simple by using keyboard macros.

Because everything you do in the editor is an "interactive command" that runs some Elisp code, it is trivial to record from your key presses the sequence of commands you are executing. And then replay them directly as code, too. There are facilities to make adjustments to the recording, if needed.
So I put my cursor under the first post in the directory, recorded my own movements as I opened the file and completed the sequence of steps, saved the changes, and moved the cursor the next file in the listing.
Then it was a matter of calling the macro for each file. Which again, it is made easy by using prefix arguments: I prefixed the command with 100, and it ran for all my posts in one go.

How sustainable is to maintain the site like this?

I have no idea. I dislike the idea of having a dynamic site, I really enjoy the static files approach (plus, Fastmail, my hosting, only supports this). It makes it easy to customize a single page if I wanted.
And the end of the day, these site-wide changes don't happen often. And I can get away with using some Emacs feature to edit all files easily, so I don't expect I will make any changes. The idea crossed my mind today, that's why I am writing this section :)
I considered putting all text in a SQLite database, then applying the templates to re-generate all pages. Or going with an existing tool, like Hugo or something like that.

But part of the fun of this is writing my own tooling and customizing all the authoring. Taking that away to learn some platform sounds pretty dull, compared to what I have now.
If I want to, getting all the content and converting to markdown or whatever, should be very simple. One more advantage of text files :)

What's next? Well, I still have to write my "detailed" about page, and add tag navigation to the site. Neither is a technical challenge, the first one is about being in the mood to write the content, and the latter about figuring out a good way to display the different page lists (in the same page as "all posts"? create an alternate page "by tag"? or one new page per tag? etc.)

Footnotes
  1. TIL the origin of Yak Shaving is related to "Ren and Stimpy". I owe to myself to watch that show start-to-finish.
  2. It is also a trap post!
  3. I mentioned the command in this recent post.

Share your thoughts (via email)

Back to top

Go to homepage