Randomize footnotes and citations HTML IDs with a variable modifier

Thank you Herb. And thank you for being so welcoming to me over the years.

I hadn’t even considered the Short ID field. I think it fulfills the goal of randomizing footnotes perfectly. While looking into this matter, I came across this blog post that describes an effort to randomize Multimarkdown footnotes using Python. The author wrote a script that would transform the required HTML code, for example, from fn:1 into fn:my-footnote-key1.

In Notenik’s case, with Short IDs we could reverse this format. Where fn:1 could become something like fn-short-id:1.[1] And likewise, #fnref:1 could become #fn-short-id-ref:1. Code for citations could follow suit.

So yes, I think Short IDs are the perfect solution to this. Thanks again!

Appendix A

I had a draft post started explaining how I tried out a workaround using Includes. It should do the trick. I was surprised at how simple it was.

This may be helpful to someone in the meantime. Since footnotes are just HTML link anchors, in the event that a variable modifier as discussed is added to Notenik, transitioning from this approach to whichever way the feature would do so shouldn’t break anyone’s web pages.


For those who may be interested in this concept in the future. I’ve found a very simple solution that involved changing about two lines of code in my templates and scripts each.

The solution

This assumes that you’re using the default Website collection.

  • Share each note intended as a post (as opposed to a static page) and export it as an HTML fragment, then write this file to the “includes” directory that is made automatically with the standard Website Collection template. I actually saved each post of mine into a subdirectory within “includes” titled “posts”.

  • Adjust the default “posts” and “teasers”templates in the factory/templates directory accordingly. The main goal is to replace the =$body$= merge command with an include command e.g. <?include "../includes/posts/=$title$=.html" ?>.

Essentially, this is it. Manually sharing your notes as HTML rather than generating them via script is necessary in order to maintain a key element: being able to edit the HTML fragment, because now you can adjust the footnote/citation HTML code to write a unique value for the id and href elements that footnotes/citations use to bounce around the web page.

Keeping the HTML for the posts isolated from the main build process (in that posts themselves are not generated, they are only included into a template) prevents Notenik from reverting any manual changes to the HTML code whenever you regenerate your website in the event that you need to edit a certain post (because Notenik will regenerate pages that have been modified).


  1. I should give credit to John Gruber, who I found using a similar format using timestamps to uniquify footnotes for Daring Fireball ↩︎

1 Like