Interested in minuet EPUB intricacies? Good, you are in for a treat!
One of the steps I mentioned for going from EPUB2 to EPUB3 is removing the toc.ncx file. This is actually a some what involved step (that is probably unnecessary) so I thought I would expand on it a bit. It also gives you a chance to poke around EPUB innards…
The NCX, i.e. “Navigation Center eXtended” was a feature to enhance navigation and accessibility based on the DAISY/NISO Standard. It was a required Spine element in EPUB2. However, the EPUB 3.0.1 spec that tells you the NCX is Superseded. Instead you are required to include an EPUB Navigation Document (i.e. nav.xhtml) that makes use of the HTML5 nav element. Basically you need to set up a <nav>, with <ol> inside, with <li> that have <a> relative links to parts of the ebook.
Since this file is a valid HTML document, it can be easily rendered by the reading device. Thus the new navigation file can serve both as a human and machine readable TOC. You can write the table of contents once in <nav>, use it at the beginning of the book (for people) and for the device to understand the reading order of the digital files to provide extended navigation.
So in EPUB3 you need a Nav doc, but do you need to get rid of NCX? No, not really… NCX Superseded says that we “MAY” include the NCX since it will not interfere with anything, “but EPUB 3 Reading Systems must ignore the NCX.” I.e. older devices will keep looking for NCX, but newer ones will definitely not.
So we have an EPUB2, we create a new Nav based TOC, the question is NCX to keep or not to keep… I really don’t have a good answer. It seems there is no reason to not keep it?
But if you want to get rid of it, building a Pure EPUB3, its more complicated than just deleting one file. Here’s what you need to do:
- Unzip your EPUB (it is probably already unzipped if you are monkeying around with the EPUB2 to 3 transition), navigate to the OEBPS directory.
- Delete the toc.ncx.
- Open the content.opf file in a text editor. This is an XML that defines the ebook.
- Look for the <manifest> element and find an <item> listing for the NCX (easiest just to search for “.ncx”). It should look something like this:
<item href="toc.ncx" id="ncx" media-type="application/x-dtbncx+xml"/>. Delete it!
- Find the <spine> element. It should have a TOC attribute that looks like this:
<spine toc="ncx">. Delete the whole attribute as it is optional in EPUB3, leaving
- Save your cleansed content.opf!