How to control the start page of a bookdown book

Viewed 323

My ebook has sections and chapters within them. Section 1 has an overview page and then chapter 1 follows. When I download my book from Amazon, it starts at the beginning of chapter 1 so the user misses the preface and the section text.

In Section 5.3 of the Amazon Kindle Publishing guidelines (https://kindlegen.s3.amazonaws.com/AmazonKindlePublishingGuidelines.pdf)

it says that "Guide items are an optional feature in the EPUB format but are highly recommended. Kindle provides support for the cover, TOC, and start reading location (”Go to Beginning”) guide items.

I'd like to specify the 'start reading' location but can't find an example how to do that.

How is this done?

1 Answers

An EPUB book is just a ZIP file, so you can unzip it and look at the files inside. A sample EPUB I created with bookdown contained a file content.opf with this <guide> element:

  <guide>
    <reference type="toc" title="A Minimal Book Example" href="nav.xhtml" />
  </guide>

According to https://ebookflightdeck.com/handbook/guide the cover and text guides would look something like this, where text corresponds to the 'start reading location':

<guide>
    <reference type="cover" title="Cover Image" href="cover.xhtml"></reference>
    <reference type="toc" title="Table of Contents" href="toc.xhtml"></reference>
    <reference type="text" title="Startup Page" href="chapter1.xhtml"></reference>
</guide>

Of course, the explicit href has to be adjusted to what is found in the EPUB.

Alternatively, you could use EPUB3 rules and add landmark items to nav.xhtml, c.f. https://ebookflightdeck.com/handbook/landmarks. Here bodymatter is probably what is needed. This might fit better, since bookdown uses EPUB3 by default. In my example EPUB generated with pandoc 2.2.1 I again get the toc, but nothing else:

<nav epub:type="landmarks" hidden="hidden">
  <ol>
    <li>
      <a href="#toc" epub:type="toc">Table of contents</a>
    </li>
  </ol>
</nav>

To get this to work I had to use:

bookdown::epub_book:
  toc: yes

pandoc >= 2.3 supports better support for specifying the different sections of an ebook using the epub:type attribute.

I am not sure how relevant this is for the kindle production, though, given this quote from the above linked publishing guidelines:

Publishers do not need to define a start reading location because Amazon does this during the upload process.

Related