How to define a TOC in HTML for kindlegen to recognize

1.1k views Asked by At

I convert a book which is written in DocBook into a single page HTML. The HTML contains a TOC:

<div class="toc">
<dl>
  <dt><span class="preface"><a href="#preface">Preface</a></span></dt>
  <dt><span class="chapter"><a href="#installation-und-versionsauswahl">1. Version Selection and
  Installation</a></span></dt>

[...]

I'd like to use kindlegen to convert the HTML into a file I can use with a Kindle. That works without a problem. BUT the TOC is not recognized as a TOC. The Kindle user can't access the TOC directly with the TOC button.

What do I have to change that kindlegen recognize the TOC in my HTML file?

2

There are 2 answers

0
Zsolt Botykai On BEST ANSWER

I'd recommend reading the official Kindle publishing guidlines from Amazon.

AFAIK kindlegen can't do that, you need a proper NCX file or an OPF with properly set TOC setting.

See also this short tutorial.

0
Alan Kent On

In case useful, I knocked up a quick PHP script to generate very basic NCX and OPF files to support the TOC without having to break up the document. I wrote the script based on a MS Word documented saved as HTML (so it is hard coded to use those style names). Just noting it here in case useful to anyone who comes along this post in the future. http://alankent.me/2016/03/05/creating-a-kindle-book-using-microsoft-word-quick-note/