That is what we were already doing, unfortunately
Our links in the ToC were of this format:
https://www.site.com/t/topic-name/ABCD/E#header--header-name
and our actual links in the posts were of this format
<a name="header--header-name"></a>
Worked for the first few posts, broke around post 8 or 9.