Ah, I think I too had $ID related issues so the TBX help file has aString attribute $AnchorName. A query finds all relevant (i.e. exporting) notes and has this action (which could equally well be a rule or edict):
Basically, we take the filename of the to-be-exported single HTML page and remove the file extension. Warning: Tinderbox only dupes exported HTML filenames at container scope, thus you need to consider if you have non-unique note names in your exporting pages and act accordingly**.
In our exporting templates, the recursing inner template includes this element for each note***:
<div class="header^value($OutlineDepth)^" id="x^value($AnchorName)^^if($IsAlias)^x^endIf^">
The ‘x’ preface in the
id value is to ensure the value string is W3C standards compliant. I’m not sure about the $IsAlias fork in the text - I think we avoided alias issues by avoiding using them (or not trying to link to them). Having exported our single page of HTML, we then run this command line on it in Terminal:
sed -E 's:href=\"help[^\.]*\/([^\.]+)\.html\":href=\"#x\1\":g' print-export-source.html > print-export-source-proc.html
** this sort of gnarly edge case is, I suspect, one reason such a feature isn’t baked into the app as export can get quite nuanced and complex without an inexpert user realising (with resultant support issues arising).
*** IIRC we avoided aliases to simplify the problem of duplicated content and broken links
If you do need aliases and/or duplicate note titles, I suggest getting your export to work without them and then add in the extra aspects so you can more easily see where breakage occurs and get ideas as how to resolve that.