How to Cook an Ebook

This part explains how to make an ebook, that is, a valid EPUB ebook, that is, an ebook that will pass the EPUB validator.

I will provide skeletons of the required files and show where to make the changes to make your ebook. You simply make the changes and paste in your chunks of text.

I won't be explaining much about the EPUB standard because I don't know much about it. To get your EPUB geek on, go to the source. All I know is that an EPUB book is a zip compressed folder that contains two folders, META-INF and OEBPS, and a file, mimetype.

The book I will build here consists of parts of the first three chapters of The Strange Case of Dr. Jekyll and Mr. Hyde and has one picture.

META-INF and mimetype

Download the zip file containing the barebones META-INF, mimetype, and OEBPS.

You can use this folder called jekyll-hyde as the starter folder for your book. Or you can make a new folder. In this case, copy the META-INF folder and the mimetype file to your book folder and forget about them.

The OEBPS folder will contain your book.

OEBPS

chapter.html

Each chapter in the book is an HTML file. Many but not all HTML and CSS effects work in the ebook.

Below is chapter.html, change the highlighted parts.

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />>
  <meta name="generator" content="TextEditor" />
<title></title>
<link href="styles.css" type="text/css" rel="stylesheet" />
</head>
<body>
  <h1 id="navigation-index">CHAPTER TITLE HERE</h1>
TEXT HERE
</body>
</html>

Change the highlighted parts. Keep the quotation marks.

Open your html file in a browser. Edit html file, then save it and update the browser to check its progress.

You can use the W3C validation service to check for errors in your html files.

In the jekyll-hyde OEBPS folder, file item_2.html is chapter 1; file item_3.html is chapter 2; and file item_4.html is chapter 3. File item_1.html is the copyright page. File item_5.html contains the credits. The last html file needed is the cover.html file. Open these files in a browser and view the source. Simply, copy and paste your text.

cover.html

Create and place your book cover image cover.jpg in the OEBPS folder. The file should be in the jpg or png format. The cover size demanded by Apple iBooks is at least 1400 pixels wide. Smashwords recommends 1600 pixels wide x 2400 pixels high.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title></title>
  <style type="text/css"> img { max-width: 100%; } </style>
</head>
<body>
  <div id="cover-image">
    <img src="cover.jpg" alt="Jekyll and Hyde"/>
  </div>
</body>
</html>

content.opf

Now that the book is written, you can complete the content.opf file.

You will need a unique identifier for your book. Each EPUB book is assigned a universally unique identifier (UUID). You can get a UUID online at ITU and paste it into the content.opf file and the toc.ncx file.

metadata

<opf:metadata>
<dc:identifier id="BookId" opf:scheme="">urn:uuid:8ffa02e0-1473-11e6-a727-0002a5d5c51b</dc:identifier>
<dc:title>The Strange Case of Dr. Jekyll and Mr. Hyde</dc:title>
<dc:publisher>Scott-Thaw Company</dc:publisher>
<dc:creator opf:role="aut" opf:file-as="Stevenson, Robert Louis">Robert Louis Stevenson</dc:creator>
<dc:contributor opf:role="bkp">Scott-Thaw Company</dc:contributor>
<dc:date opf:event="creation">2016-05-07</dc:date>
<dc:date opf:event="modification">2016-05-07</dc:date>
<dc:date opf:event="publication">2016-05-07</dc:date>
<dc:language>en</dc:language>
<opf:meta name="cover" content="image_cover" />
<opf:meta name="generator" content="EPUBLib version 3.0" />
</opf:metadata>

"image_cover" is id for the book cover in the manifest coming up next.

manifest

The manifest lists all of the resources, pictures, text, etc., used in the ebook.

Assign a unique item id to each resource.

<opf:manifest>
<opf:item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" />
<opf:item id="image_cover" href="cover.jpg" media-type="image/jpeg" />
<opf:item id="cover" href="cover.html" media-type="application/xhtml+xml" />
<opf:item id="title_page" href="item_1.html" media-type="application/xhtml+xml" />
<opf:item id="chapter_1" href="item_2.html" media-type="application/xhtml+xml" />
<opf:item id="picture_1" href="flattened-girl.jpg" media-type="image/jpeg" />
<opf:item id="chapter_2" href="item_3.html" media-type="application/xhtml+xml" />
<opf:item id="chapter_3" href="item_4.html" media-type="application/xhtml+xml" />
<opf:item id="credits" href="item_5.html" media-type="application/xhtml+xml" />
<opf:item id="styles" href="styles.css" media-type="text/css" />
</opf:manifest>

spine

The item ids for the html files are referenced in the spine.

<opf:spine toc="ncx">
<opf:itemref idref="cover" linear="no" />
<opf:itemref idref="title_page" />
<opf:itemref idref="chapter_1" />
<opf:itemref idref="chapter_2" />
<opf:itemref idref="chapter_3" />
<opf:itemref idref="credits" />
</opf:spine>

toc.ncx

In this file, the navPoint id "navi-point-n" is the same as the id for the chapter header <h1 id="navi-point-n"> in the corresponding chapter.html file.

<?xml version='1.0' encoding='UTF-8' standalone='no' ?>
<ncx version="2005-1" xmlns="http://www.daisy.org/z3986/2005/ncx/">
<head>
  <meta name="dtb:" content="urn:uuid:8ffa02e0-1473-11e6-a727-0002a5d5c51b" />
  <meta name="dtb:generator" content="EPUBLib version 3.0" />
  <meta name="dtb:depth" content="1" />
  <meta name="dtb:totalPageCount" content="0" />
  <meta name="dtb:maxPageNumber" content="0" />
</head>
<docTitle>
<text>The Strange Case of Dr. Jekyll and Mr. Hyde</text>
</docTitle>
<docAuthor>
<text>Stevenson, Robert Louis</text>
</docAuthor>
<navMap>
  <navPoint id="navi-order-1" playOrder="1" class="chapter">
  <navLabel>
  <text>The Strange Case of Dr. Jekyll and Mr. Hyde</text>
  </navLabel>
    <content src="item_1.html#navi-order-1" />
  </navPoint>
  <navPoint id="navi-order-2" playOrder="2" class="chapter">
  <navLabel>
  <text>Story of the Door</text>
  </navLabel>
    <content src="item_2.html#navi-order-2" />
  </navPoint>
  <navPoint id="navi-order-3" playOrder="3" class="chapter">
  <navLabel>
  <text>Search for Mr. Hyde</text>
  </navLabel>
    <content src="item_3.html#navi-order-3" />
  </navPoint>
  <navPoint id="navi-order-4" playOrder="4" class="chapter">
  <navLabel>
  <text>Dr. Jekyll Was Quite at Ease</text>
  </navLabel>
    <content src="item_4.html#navi-order-4" />
  </navPoint>
  <navPoint id="navi-order-5" playOrder="5" class="chapter">
  <navLabel>
  <text>Credits</text>
  </navLabel>
    <content src="item_5.html#navi-order-5" />
  </navPoint>
</navMap>
</ncx>

Finishing Up

Zip the book folder that contains META-INF, mimetype, and OEBPS to create the EPUB zip file of your book. Rename book.zip to book.epub.

I use the app eCanCrusher to zip because the zip on the Mac inserts a file called .DS_Store, which causes a validation error.

Check the EPUB book here.

Read your book in your favorite EPUB book reader.

Book cover of Jekyll and HydeFinished ebook of a truncated Jekyll and Hyde

Here are skeleton files of chapter.html, content.opf, and toc.ncx to fill up.