Here’s something I have achieved today: I got my site to display an “external link” SVG icon at the end of all links generated from Markdown, using Hugo’s neat markdown render hooks . Basically, when Hugo is translating Markdown source files into an HTML built site, it turns Markdown links into HTML ones following a certain template – but by creating …
Posts tagged ‘web dev’
It’s been bugging me for a while that Vercel is generating incorrect “last modified” datetimes for my wiki pages on this site. What it seems to be doing is getting the last modified date only if it’s within the ten most recent commits. If the last modification was further back than that, it prints the last modified datetime of the tenth-most recent commit. From the docs it looks like Vercel is not even fetching git commit author dates (but commit SHAs and commit author logins, those it fetches…), so instead I guess it stores some cache that only goes back ten commits? I have no real clue, but because I don’t know how to fix this, I’ve commented out the part of my template that generated “last modified” text for my wiki pages. Better to display nothing than to have it display something that’s wrong for the vast majority of pages…
I mean… one way to fix this would be to build my site using GitLab’s CI/CD and just upload the built files to Vercel, instead of GitLab merely passing the source files along for Vercel to build. But ugh, what a hassle to change that all around 😩 Another strategy would be to manually set a “last modified” date in the front matter of pages I want to have one, and display that in preference to whatever
git says. (Or even disable
enableGitInfo entirely, if it’s just resulting in junk data.) That’d also be annoying, though. So, for the moment, I think just not displaying “last modified” dates’ll have to be the go.
Since I made the switch to a narrower main column and larger text, I’d been feeling like the “jagged right edge” of my posts had become much more noticeable. The fewer words there are on each line, the greater a proportion of a line each word occupies, you see, which means that when a long word was too long to fit on the end of a line and was forced to become the first word of …
I said the other day that I would figure out how to customise the syntax highlighting for the Nord theme , and now I have. If you want to grab the stylesheet for yourself, I’ve uploaded it as a snippet on GitLab . Some quick usage notes (which you’ll find in briefer form at the snippet page, too):
First, make sure your Hugo config file sets …
So, this is not the ground-up overhaul I mentioned wanting to do in yesterday’s entry. (If it was, there wouldn’t be so much wasted horizontal space on desktop.) However, if there’s one thing that’s true about myself, it’s that sometimes my brain just won’t let go of an idea. Even if it was something I had no intention of doing any time soon, once my internal …
As different platforms have implemented built-in “dark mode” functionality over recent years, it’s become increasingly popular. I’m all for people having options so their individual computing set-ups can be as comfortable as possible for them, but for me personally, I can’t stand most layouts that put bright text on dark backgrounds, so I don’t use dark mode. …
Uhh, well here’s a little Vercel quirk to be aware of: its default build command for Hugo repositories builds all your drafts as if they were ready-to-go finished posts 🤯 It’s not like I had a burn book stashed away in my Hugo drafts or anything but it’s definitely something I wish I’d noticed yesterday! TBH it’s so random it hadn’t even occurred to me they could possibly be doing that – the “build drafts” flag
-D is something you have to explicitly add to the basic
hugo build command, after all. Fixed now, anyway.
On the off-chance you noticed a couple of hours’ downtime earlier today, that’ll be because I moved this site’s hosting over to Vercel . I made the move for a couple of reasons:
- As I mentioned, I decided to move my writing repository over to GitLab, and if I was doing that I thought I might as well move my other personal projects at the same time. (GitLab also allows you to host larger repositories on their servers – useful if I keep this site going for years and upload lots of photos – and there are of course political reasons why lots of people hate Github.) However, the idea of having to rewrite my Github Workflows file for GitLab’s CI/CD system made me sad.
- I wanted a hosting solution that had a CDN integrated into it, so ordinary HTML pages can actually be cached (so they’ll load fast, from cache, on most pageloads) but the cache invalidates automatically when I update my site (so new posts can be seen on my home page/in feeds/etc. straight away, not hidden behind a stale cache). I never worked out how to achieve this when my hosting and CDN were separate, even though I figured it was possible by processing the output of
rsyncand sending the output as a list of URLs to purge through the CDN’s API.
At any rate: full credit to Vercel, they made deploying my site from my GitLab repository unbelievably easy. Updating the DNS records for my domain was just as easy, but DNS caching meant it took a couple of hours for the change to go live. As for “why Vercel and not Netlify” or any other similar platform, well… the usage limits on Vercel’s free platform were just a bit more generous. Not that I think I’d have gone over Netlify’s limits anyway, but it’s nice to have some peace of mind 🤷🏻♀️
I think the DNS has all updated now, so that’s that: I’m now serving my site through BunnyCDN , which should mean pages, images etc. will load from a server geographically close-ish to each visitor, rather than always from my shared host’s server in the US. The real load time savings will come as more of the site actually gets cached on the CDN servers, of course, so Bunny doesn’t have to fetch so much from the slow shared hosting server.
It might seem like a bit much for a personal homepage, but Bunny is very cheap (the minimum cost of US$1 per month covers up to 100GB of bandwidth, depending on where your visitors live), and the slowness with which my own site loaded here in Australia was really annoying me. So here’s to fast loading speeds!
I’ve run into more obstacles than I thought I would, but not only do I have an Indiekit Micropub endpoint up and running now (but not working for media uploads yet), but I’ve also set up continuous deployment with Github Actions, so my static Hugo site rebuilds after every new post. This guide here was really helpful for the Github Actions stuff, and the only reason I lost three hours of my life afterwards is that I missed the really critical information that it’s written assuming you haven’t set a custom value for
publishdir in your Hugo config file. Whoops.
Anyway, I have more tinkering I want to do, but I’ve been staying up late night after night and it’s time I treat myself to getting into bed before midnight. My site will still be there to tinker on tomorrow, after all…