Note: For those following the above thread and wondering why I can’t easily implement the advice I was given, the problem is that I am also keeping each “title” file — what’s being overlaid in each case — separately on my local drive apart from the repo, hence the additional need to maintain separate files with unique filenames. Moreover: the whole point of this was to give me more control over the OG/Twitter card’s appearance. I used Hugo’s built-in text filter for a while, which is much simpler from a coding standpoint — but, at this writing, it doesn’t allow control over the overlaid text’s alignment (left-align only), its right-side padding (x-start and y-start only), or its word-breaking. …Hence, what I’ve done here. If those features ever get added to the text filter, it’ll be far and away a better choice.
Further edit from the next day: Also for those who find this thread later, I reconsidered the (as-always) excellent advice of @jmooring and decided to re-build my site that way. (At this writing, I’m finishing that up in a branch, but things are going well enough that I’ll probably merge it into main later today.) He’s absolutely right that it is far less error-prone and, as an added benefit, makes the coding much simpler.
I haven’t converted mine yet. Only a few. Initially, I wanted to keep my files as I used them in Jekyll in case I wanted to switch platforms (I was trying Hugo, Eleventy and Zola). But since I settled on Hugo, I am still thinking about converting all files to page bundles (nearly 300). So, I am still not converting mine until I decide to do so in the future.