building this site #2
Many features I’ve implemented on this site – e.g.
revisionsbuilding this site
In the spirit of making this site dynamic
like a virtual book, I added modified dates and revisions.
Firstly, I added modified dates to all posts and a way to sort them by post date or modified date. This discourages me from treating posts like static pieces and instead encourages me to edit, rework, and reimagine them. I didn’t want to be responsible for manually updating the modified date of a post, so I automated it.
For my first attempt at implementing it, I put together a plugin written in Ruby (mostly written by GitHub Copilot) that found the most recent commit’s date for each post by looking through the Git history.
It worked, but it also slowed down my local build a lot.
I found a much better solution: set up a git pre-commit hook that updates the modified_date
in a post’s frontmatter when a change is committed to it.
To implement sorting, I had to use JavaScript.
Working on a static website has made me appreciate how much is possible without JavaScript and what isn’t.
More challenging to implement and more exciting to complete was a feature I’m calling Revisions, which shows past edits of select posts. This one was even more important to automate. Manually creating a revision for every new post would be a ponderous task that would deincentivize me from making changes. Automatically generated revisions, on the other hand, excite me to make changes. I want to see how posts change over time and how the converge to “final” form.
So, the main task was to plug into the Jekyll build to generate new pages that represent the difference between every pair of sequential commits in a post’s Git history. Once I had that, I just had to do some minor coding in HTML and Liquid to add links in a post’s metadata to link to its revisions.
After I figured out how to get the full Git word diff between two commits (the git
gem’s API apparently doesn’t expose this part of Git’s functionality), most of the trouble had to do with formatting: stripping Git diff metadata, replacing diff markers with markdown formatting, transforming Markdown to HTML, and styling the HTML.
After I finally got it working locally, I pushed it up to GitHub to kick off the build and publish job.
But after the GitHub Actions finished, the site didn’t look any different!
It took me a while to figure out why the GitHub Pages build was passing but not generating any revisions.
I figured the git
gem wasn’t being installed since it isn’t in the list of packages supported by GitHub Pages.
It seemed like the plugin wasn’t running at all.
Only after I added print statements to it did I realize that it was running, but only finding a single commit.
Finally, I fixed it by setting the fetch-depth
of the checkout
action to a pseudoinfinite number so that the full Git history would get processed.
I set it up so I can easily enable or disable revisions for a post by setting show_revisions
in its frontmatter.
So far, I’ve enabled revisions for
,
how to think invisibly, and
how to tell a story #3.
– encourage retroactive editing of posts. Today, I implemented a minor feature in the same spirit: configurable redirects. This allows me to easily give a post a new URL without making its previous one(s) obsolete. All I have to do is make two configuration changes in the frontmatter of the relevant post:
- Specify the new URL via the usual
permalink
property e.g.'/why-write'
. - Add the old URL to the list specified by
redirect_from
e.g.['/justify-writing']
.
For example, I changed
okjuan.me/vbook/justify-writingwhy write?
Writing The Virtual Book forced me to ask: when is writing the best medium?
Something wonderful about writing is its economy. The only equipment you need is brain, paper, and pen. To document a journey through the Alaskan wilderness, for example, you don’t need to bring cameras, microphones, or personnel. The trip continues without the slowing of setup and teardown. You move as you would if there wasn’t a writer tagging along.
What’s more, there is no extra gear or logistics to obstruct encounters with the landscape and your fellow humans. The writer and all others are freed into the experience.
The experience is different for the audience, too. Writing sacrifices the sensorial experience for one deeper into the realm of imagination. The action is staged entirely in the mind. The reduction of reality into abstract symbols is both a restriction and a release. A loosed connection to time and space means the reading experience is less grounded in reality, but also less confined to it.
to
okjuan.me/vbook/why-writewhy write?
Writing The Virtual Book forced me to ask: when is writing the best medium?
Something wonderful about writing is its economy. The only equipment you need is brain, paper, and pen. To document a journey through the Alaskan wilderness, for example, you don’t need to bring cameras, microphones, or personnel. The trip continues without the slowing of setup and teardown. You move as you would if there wasn’t a writer tagging along.
What’s more, there is no extra gear or logistics to obstruct encounters with the landscape and your fellow humans. The writer and all others are freed into the experience.
The experience is different for the audience, too. Writing sacrifices the sensorial experience for one deeper into the realm of imagination. The action is staged entirely in the mind. The reduction of reality into abstract symbols is both a restriction and a release. A loosed connection to time and space means the reading experience is less grounded in reality, but also less confined to it.
.
If I later decide to change the URL again e.g. to okjuan.me/vbook/why-i-write, I just have to set permalink: /why-i-write
and redirect_from: ['why-write', '/justify-writing']
in the post’s frontmatter.
A nice side-effect of this change is that I can make a post’s URL match its title even if I change it. Another perk is that I can easily update okjuan.me/vbook/now to point to my latest what I’m doing now post. But probably this feature’s most useful effect, and the reason I thought to implement it in the first place, is that it lets me realign a post into a series. For example, by changing the title of how to justify writing to why write?, I can make it the first entry in a series that I can create by writing posts why write? #2, why write? #3, and so on.