Roundtripping endnotes for EPUB from InDesign
Have you poured a long, complex Word file with hyperlinked endnotes into InDesign only to find their interactivity disappeared? Or maybe you managed to salvage the link to the endnotes but now you are wondering why there is no backlink from the endnote back to it’s reference point in the text in the EPUB?
I came up against this recently and felt very dumb. This can’t be that tricky to accomplish, can it? It’s not, but it took a fair bit of research, frustration, and whining to figure out a solution. I am going to explain my process but please tell me about yours. I am eager to find new efficiencies if at all possible.
A central character in this story is Peter Kahrel, scripter extraordinaire. A quick Google search about footnotes endnotes hyperlinking InDesign returns links to his website. He has already thought this question through and is, in fact, the hero of this story.
The first step is to make sure that the notes in your source Word file are footnotes, not endnotes. If they are endnotes, convert them to footnotes in a duped file that is for InDesign import only. The process is explained in detail here, but briefly:
- In “draft” view, go into View –> Footnotes
- Select all footnotes, then control-click opting for “Convert to Endnote”
It may take a minute depending on how big your document is and how strong your Word-fu is (mine isn’t), but that’s it.
Step Next is to install these two InDesign scripts in the scripts folder of whichever version of InDesign you are running. On this page, down at the bottom, you will find two scripts: “Footnote-to-endnote” script, and the “Return Links” script. You will need both.
Once the source Word file is imported into an InDesign template, running the first script will change the footnotes to endnotes, creating one-way hyperlinks via InDesign’s cross-referencing function, which you can see via the Cross References panel. The endnotes will be in a numbered list now.
Pay attention to the numbering of these references and mind any whose link has gone red. They must be sequential, and must be green in order for the next step to work without a hitch.
The second script will convert the list to live text and create return hyperlinks around the live note number. It needs consistently and cleanly applied style sheets in order to work well, in addition to no gaps at all in the footnote number sequence. Important caution: duplicate the file before you run the return link script. As someone who worked on a file with 641 endnotes who ran the script without a backup file and with gaps in the sequential order of the notes, I can tell you that this is not a mistake you want to make. Please learn from my terrible error.
Once boths scripts are run, the EPUB that you create from this file will have two-way endnote links. You won’t have to bend your mind to run fancy RegEx strings in order to add backlinks.
One final note: Peter Kahrel has generously made these scripts available for free. Please consider making a donation to him for his time and know-how via the PayPal link at the very bottom of the script page.
Thank you Laura for this clear explanation and abundant cautions. Peter Kahrel is a national treasure. If InDesign users had their own currency, his face would grace the $100 bill.
Thanks for a great first article Laura!
Hope there will be many more! (no pressure! 😊)
I’m so glad you’ ll be feeding the ePubSecrets page!
I’ve just hit the email notification button again!
This is a timely post about a great script. I have a couple of tips, learned the hard way the last week when using endnotes_references_hyperlinks.jsx
1. The story with text references and the story with the references themselves must be threaded together. The script doesn’t work if they are separate stories. (You’ll get Error 30477.) This certainly makes sense, but it took quite a while to figure it out. Actually, I didn’t figure it out. I wrote to Peter and he clued me in.
2. If you run the script and it fails to complete its mission (as happens if the text refs and references are not in the same thread), you’ll leave behind an artifact at the text-ref location. That artifact of a link will block the script from running again. (You’ll get Error 79111.) If you’ve done this, the workaround is to delete each text reference and re-enter it, applying the character style again. Once more, Peter helped me figure this out.
In fact, when I mentioned to him that I had several hundred refs to change, he sent a small script that does that.
I really want to repeat Laura’s request at the end of her post: Please donate to Peter if you use any of his scripts. They’re huge time-savers, and the fact that he responds quickly and thoroughly to questions is a great benefit.
Thanks, Maryse.
I have tested it and found that it is working fine. However two way links are functioning in the ePub exported from InDesign CC 2015 and InDesign CC 2017 even without running the scripts.
Maryse. Hi. I have a question. This might not be the place.
What if I have a book (single file) already formatted in InDesign (originally for print, but now retro-fitting for ebook). There are well over 200 endnotes. There are no links. Reading this it makes me this I am out of luck. Did I misunderstand? Thank you.