BB eBooks Banner

EPUB 2.0.1 Boilerplate for eBooks

The eBook Design and Development Guide

eBook Design Development Guide Cover

For complete access to all the templates, tips, and tricks that BB eBooks uses for eBook production, please consider buying the eBook Design and Development Guide at Amazon for only $6.99. In it you will find comprehensive HTML, CSS, and Regular Expression tutorials, as well as a step-by-step workflow for turning a sloppy manuscript into a beautiful eBook that is only available in this guide. A PDF version is available upon request following purchase.


mimetype file

This file must be in the root directory and must be exactly 20 bytes. Do not add any white space.

application/epub+zip

container.xml file

This XML file must be in a directory called META-INF. The full-path attribute specified in the rootfile element points towards the OPF file relative to the root directory.

<?xml version="1.0"?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
  <rootfiles>
    <rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml"/>
  </rootfiles>
</container>

content.opf file

This XML file should be in a directory called OEBPS. The relative paths in the manifest section are relative to the opf file if you want to have your HTML, CSS, and images in separate directories.

<?xml version="1.0" encoding="utf-8" ?>
<package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId">
  <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
    
<!--Required metadata-->
<dc:title>Crime and Punishment</dc:title> <dc:language>en-us</dc:language>
<!--Other examples include "en-gb" for British English, "fr" for French-->
<dc:identifier id="BookId" opf:scheme="uuid">urn:uuid:3e3f969b-c287-4327-bcdd-4f7eda7c9411</dc:identifier>
<!--Above identifier is an example of a UUID. You can obtain one here http://www.guidgenerator.com/online-guid-generator.aspx To use an ISBN, it would look as follows: <dc:identifier id="BookId" opf:scheme="ISBN">urn:isbn:1234567890123</dc:identifier> -->
<dc:creator opf:role="aut">Fyodor Dostoevsky</dc:creator>
<!--The Author-->
<dc:publisher>BB eBooks</dc:publisher>
<!--Name of Publisher or yourself if self-published-->
<dc:date>2012-06-15</dc:date>
<!--Published Date in the format YYYY-MM-DD-->
<meta name="cover" content="My_Cover_ID" />
<!--Required for KindleGen-->
<!--Extra metadata here (recommended)-->
<!--Backjacket description goes here-->
<dc:description>This is classic Russian literature!</dc:description>
<!--These function like Keywords. Use as many as you like-->
<dc:subject>Russian</dc:subject> <dc:subject>Classics</dc:subject>
<!--This is optional metadata that rarely gets used-->
<dc:rights>All rights reserved</dc:rights> <dc:type>Text</dc:type> <dc:source>Can be a URL or ISBN number</dc:source>
<!-- A prior resource from which the publication was derived -->
<dc:relation>Can be a URL or ISBN number</dc:relation>
<!-- An identifier of an auxiliary resource and its relationship to the publication -->
<dc:coverage>Worldwide</dc:coverage> </metadata>
<!-- The media-type attributes in the manifest are just mimetypes. Some other examples: gifs: "image/gif" jpegs: "image/jpeg" PNG: "image/png" otf: "font/opentype" ttf: "font/truetype" -->
<manifest> <item href="cover.jpg" id="My_Cover_ID" media-type="image/jpeg" /> <item href="toc.ncx" id="ncx" media-type="application/x-dtbncx+xml" /> <item href="coverpage.html" id="htmlcoverpage" media-type="application/xhtml+xml" />
<!-- Do not add a coverpage.html file for the Kindle -->
<item href="content001.html" id="htmlcontent001" media-type="application/xhtml+xml" /> <item href="htmltoc.html" id="htmltoc" media-type="application/xhtml+xml" /> <item href="content002.html" id="htmlcontent002" media-type="application/xhtml+xml" /> <item href="bbstylesheet-epub.css" id="cssbbstylesheet-epub" media-type="text/css" /> <item href="myimage.jpg" id="img1" media-type="image/jpeg" /> </manifest> <spine toc="ncx"> <itemref idref="htmlcoverpage" /> <itemref idref="htmlcontent001" /> <itemref idref="htmltoc" /> <itemref idref="htmlcontent002" /> </spine> <guide> <reference href="coverpage.html" type="cover" title="Cover" />
<!--For Kindle, do not include the Cover guide item -->
<reference href="htmltoc.html" type="toc" title="Table of Contents" /> <reference href="content002.html" type="text" title="Beginning" />
<!-- For Kindle, the eBook opens to this HTML file when the user first opens the eBook -->
</guide> </package>

toc.ncx file

This XML file specifies the NCX Table of Contents. Ensure that the playOrder attribute is numbered sequentially. Thankfully, this bloated format is going away with EPUB 3.

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN" "http://www.daisy.org/z3986/2005/ncx-2005-1.dtd">
<ncx xmlns="http://www.daisy.org/z3986/2005/ncx/" version="2005-1" xml:lang="en">
  <head>
    <meta content="urn:uuid:3e3f969b-c287-4327-bcdd-4f7eda7c9411" name="dtb:uid" /> 
<!-- Must be exactly the same as dc:identifier in the content.opf file -->
<meta content="1" name="dtb:depth" />
<!-- Set for 2 if you want a sub-level. It can go up to 4 -->
<meta content="0" name="dtb:totalPageCount" />
<!-- Do Not change -->
<meta content="0" name="dtb:maxPageNumber" />
<!-- Do Not change -->
</head> <docTitle> <text>Crime and Punishment</text> </docTitle> <docAuthor> <text>Fyodor Dostoevsky</text> </docAuthor> <navMap> <navPoint id="ncxcoverpage" playOrder="1"> <navLabel> <text>Cover</text> </navLabel> <content src="coverpage.html" /> </navPoint> <navPoint id="ncxcontent001h1-1" playOrder="2"> <navLabel> <text>Chapter 1</text> </navLabel> <content src="content001.html#h1-1" /> </navPoint> <navPoint id="ncxcontent002h2-1" playOrder="3"> <navLabel> <text>Chapter 2</text> </navLabel> <content src="ontent002.html#h2-1" /> </navPoint> </navMap> </ncx>