Note to mwra: Might it be practical to set $HTMLExportFileName to $Name for every note in the document, e.g. through an agent action? If one did this, then (I think) everything else follows correctly.
I fear that might just shift the problem. A valid $Name can contain characters that aren’t web-safe without further intervention. Plus, we’re sort of fixing the wrong problem.
The issue I created for @Gilberto was that by using part of $HTMLExportedPath for the link anchor text I got a ‘web-ified’ version of the title rather than the value of $Name as might reasonably be expected. My bad for using too-simple test note titles.
I think the real solution here is for an action code wrapper that renders the equivalent of ^linkTo()^.