Alternative way to create an ePub table of contents

I love Scrivener. That said, I have had a lot of trouble using it to create a table of contents. Something always goes wrong, often in weird ways.
For ePub files, there is an alternative.

An ePub file is a zipped (compressed) file containing a number of XHTML files—one XHTML file per book chapter, plus a few extra files for things like the table of contents.

An XHTML file is the same as an HTML file, with one main exception: HTML is error-tolerant, XHTML isn’t. For example, if you have an

  • (open list element) tag, you must have a matching
  • (close list element) tag.
    If you know a little HTML, or are brave enough to learn just a little, you can understand XHTML. Actually, if you don’t want to apply extra formatting to your table of contents, you can probably get away without knowing any HTML at all.

    Sigil ( is a free program for editing XHTML files. There are pre-built binaries which you can easily install; just look for the releases, and download a txz file for the Mac or an exe file for Windows. Sigil is big and powerful, but don’t be intimidated; what we’re going to do is easy.

    1.	Run Sigil.
    2.	Use Sigil to open your ePub file.
    3.	Click on [b]Tools:Table of Contents: Generate Table of Contents…

    [/b] 4. Check the entries you want to include. At the bottom there is a checkbox to show you either everything that might be in the index, or just the entries you have checked.
    5. To change the indentation of an entry, choose it and click the < or > buttons.
    6. Click OK.

    You now have a file contents.xhtml. (If you had one before, it’s been replaced.) If the file isn’t where you want it, you can click on it in the Book Browser pane and drag it to where you want it. Then save in the usual way, or quit without saving.

    Sigil shows you what your XHTML will look like in the Preview pane, but you can’t edit it there. If you want to do additional editing, you have to do it in the XHTML. Sigil will check your XHTML for XHTML errors as you edit.
    Finally, if you want to do any further editing, legal XHTML isn’t necessarily legal ePub. EPub has some additional constraints. EPUB Validator ( can catch any additional problems, and it will tell you exactly where in Sigil to look to fix them.