XHTML and Blogger permalinks
Thanks to a blessedly bad memory, I had forgotten about the next archive-related problem with AKMA’a markover: permalinks. XHTML requires that, rather than using <a name=”<$BlogItemNumber$>”> for a permalink, you must use an id attribute, which may not start with a digit. Something along the lines of <a id=”pl<$BlogItemNumber$>”> will do nicely. For someone who is starting from scratch, that’s easy enough, but when you have thousands of links pointing at thousands of existing permalinks that start with a digit, it’s a problem.
As an aside, prior to the arcane solution, let me mention the alternative of embracing my philosophy of validation. I don’t see validation (to any spec, much less XHTML) as an end, but merely as a tool. By keeping your pages fairly close to valid, and knowing why they are invalid in spots, you can use the validator as a quick check when something goes wrong. Beyond that, a slavish devotion to validation at all costs is more likely to cause problems (since there isn’t any browser that fully and reasonably supports every W3C spec) than solve them.
However, there is a solution of sorts to AKMA’s permalink problem, and what’s more, it will give him the opportunity to get his hands dirty, and soon. To preserve existing links while making the new ones valid XHTML, we will have to live with slightly invalid older archives. Here’s what I would do:
First, following your last post on a Saturday night (because weekly Blogger archives run from Sunday morning to Saturday night), make absolutely certain that all the archive files are on your server, and in good shape, with every post present and accounted for. Then, for safety’s sake, stop Blogger from overwriting them, by chmodding them ‘444’ (only read permission, for owner, group, and world). If you really want to overwrite them, you still can, by chmodding them back to ‘644’, but you won’t accidently, while using republish all to resurrect your archive index.
Next, comment out the permalink target (the <a name=”<$BlogItemNumber$>”>) and also the permalink code (the <a href=”<$BlogItemArchiveFileName$>#<$BlogItemNumber$>”>), inserting an explanation of why it’s commented out but still there: something like
<!– old html version <a name=”<$BlogItemNumber$>”> –>
Then, insert the spiffy new XHTML version of both pieces (<a id=”pl<$BlogItemNumber$>”> and <a href=”<$BlogItemArchiveFileName$>#pl<$BlogItemNumber$>”>), save the template, and wait until Sunday morning to publish, when the new archive file will be created with new XHTML anchors. (Later: it occurs to me that this will make the older posts which are still on the main page give incorrect permalinks until they fall off the main page: in the archive files the anchors will be unprefixed, but the main page links will be prefixed. Um. I don’t actually have a solution for that, right offhand.)
Making changes to archive files will then involve uncommenting the old versions, commenting out the new versions, chmodding to get write permission, publishing the pre-switch archives, then changing back and publishing the post-switch archives, but it will work to get the maximum amount of valid XHTML without breaking existing links.
You can’t use mod_rewrite to modify permalinks because the anchor is not passed to the server; it’s done client side. So, to those who are interested in eventual XHTML compliance, I wouldn’t recommend putting this off, even if you’re planning to move to Apache soon.
I probably should have known that. Thanks: you saved me a bit of testing (I had just gotten my test set up, hadn’t actually run it yet). I would have been blaming my regexp for quite a while before I figured it out. Guess I’ll edit that mod_rewrite bit out of the post. Too bad, since that was the only really tolerable way to do it.
it sounds like so much hard work to me
and I already have enough broken code to deal with
Phil, dont ever stop supporting blogger users – or blog users for that matter – you are an internet treasure and we value all of your insights immensly!