The Other Files: So You Want to Make an eBook?

This post is part of So You Want to Make an eBook?. I’m releasing this book in sections on my blog, but when it’s all finished I will offer the whole thing as a single eBook. Everyone who donates toward its production (use the coffee cups to the right, note that it’s because of this effort) will get a free copy of this eBook. You can find all the posts here.
The Other FilesThere are several other files we haven’t touched on that belong in our ePub. We’ll hit on each of them here. The first two are container.xml and a file called mimetype. mimetype simply says what the ePub is, and container.xml simply says where the files are. They’re in the example file you downloaded from my site. Look at them, but don’t alter them. A special note about mimetype: Make it the very "first" file in your finished ePub. Not the first in the directory, the first in the file Remember, an ePub is a just ZIP file with a special structure. Some eReaders get picky about the first bit of the file, and expect to find the mimetype file right at the beginning. Epubcheck will definitely throw an error about this.
It’s an easy fix: create a new ZIP file (using "Send to Compressed File" on Windows or your third party solution) with only the mimetype file in it. After that, you can add, remove, and otherwise manipulate the other files in the archive at your leisure. Ubuntu (and other Gnome) Linux users: Fileroller does not preserve the file order, and you will get errors later on.Next, you’ll see toc.ncx. This is one of the two files that handles the built-in table of contents. This is not the same as the table of contents we created above. We’ll walk through the basic enclosed example. It’s worth noting that this example comes from a real project, and so would have to be edited.Leave the top part of the file alone; it’s fine as it is. Skip down to the <docTitle> tag. Put the title of your eBook between the opening and closing <text> tag.Then there’s the navigation map. Again, it’s made of nested tags, starting with (naturally), <navMap>. Afterward, there will be a navagation point for each file (chapter) that a reader sees. With the navPoint opening tag, each item gets an id that is unique within that file. playOrder refers to – you guesed it, where the file is in the display sequence. The <navLabel> tag is just like <docTitle>, except that it has the chapter name in it, and then content src points to the actual filename. As with the other files, each opening tag closes again, and then it all closes with </ncx>.Pretty straightforward. (At least, when you look at the file.)Then there’s content.opf. There is a lot of information that you can put in the metadata portion of this file, but you’ve got to do it correctly. We’ll deal with that first. You should be somewhat familiar with the idea of markup now – and how each item is open and closed.I am sure that there are more possible items that you can stuff in the metadata here – but I can’t guarantee that all readers will recognize them. Therefore, we’ll stick with the basic ones. Take a look at the example. The first three lines should all stay the same. Then we get to the rest: <dc:title>The Book Title</dc:title><dc:description>The back cover copy for your book. Keep it short, some eReaders truncate this text.</dc:description><dc:creator opf:file-as="AuthorLast, Firstname" opf:role="aut">Firstname AuthorLast</dc:creator><dc:date>2010-09-12</dc:date><dc:identifier id="BookId">Unique Book Identifier, can be ISBN</dc:identifier><dc:language>en</dc:language><dc:subject>Keyword</dc:subject><dc:subject>Another Keyword</dc:subject><dc:creator opf:role="aut">Firstname AuthorLast</dc:creator><dc:publisher>Your publisher, or your name or website.</dc:publisher><meta name="cover" content="cover.png"/> The file content.opf also has an exhaustive list of all the files associated with the book. This is under both the manifest and spine toc sections. The examples below (which are also in the example file)
cover the most common file types. Order is not important in the manifest section. <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/><item id="style" href="style.css" media-type="text/css"/><item id="cover" href="cover.png" media-type="image/png"/> <item id="coverpage" href="CoverPage.html" media-type="application/xhtml+xml"/><item id="id1" href="chapter_00.html" media-type="application/xhtml+xml"/><item id="id2" href="chapter_01.html" media-type="application/xhtml+xml"/> The id of each item can be whatever you want it to be (as long as it starts with a letter) – but making it short and simple is in your best interest. Immediately after the manifest section comes the spine toc – and order does count here. <itemref idref="coverpage"/><itemref idref="id1"/><itemref idref="id2"/><itemref idref="id3"/><itemref idref="id4"/> Now you zip (compress) all of these files into, and rename it to myebook.epub. You can, of course, call it something other than "myebook". When you name it something else, keep the filename short-ish and try to avoid spaces in your filename. Again, making your life easier.This post was part of So You Want to Make an eBook?. I’m releasing this book in sections on my blog, but when it’s all finished I will offer the whole thing as a single eBook. Everyone who donates toward its production (use the coffee cups to the right, note that it’s because of this effort) will get a free copy of this eBook. You can find all the posts here.

blankWas this post helpful or insightful? Buy me a coffee here or here and share this post with others!

Popular posts:

  • The difference between boundaries and rules
  • Two Ways to get CMYK Separation Using GIMP Instead of Photoshop in 2022
  • Word Porn Quotes
  • Weekend Project: Whole House and Streaming Audio for Free with MPD
  • Organizing and Tiling Your Windows on #Openbox Using Only... Openbox
  • Odds and Ends: Optimizing SSHFS, moving files into subdirectories, and getting placeholder images

Recent Posts


  1. June 9, 2012

    Do you include the image and style file ids in the spine section?

  2. June 11, 2012

    Nope. The spine is just a series of references to the ids in the manifest section:

    <item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/>
    <item id="style" href="style.css" media-type="text/css"/>
    <item id="a_1" href="section_000.html" media-type="application/xhtml+xml"/>
    <item id="a_2" href="section_001.html" media-type="application/xhtml+xml"/>
    <item id="a_3" href="section_002.html" media-type="application/xhtml+xml"/>
    <item id="a_4" href="section_003.html" media-type="application/xhtml+xml"/>
    <item id="a_5" href="section_004.html" media-type="application/xhtml+xml"/>
    <item id="a_6" href="section_005.html" media-type="application/xhtml+xml"/>
    <item id="a_7" href="section_006.html" media-type="application/xhtml+xml"/>
    <item id="i_div1.jpg_558" href="images/author.jpg" media-type="image/jpeg" />
    <item id="i_enchanted.jpg_334" href="images/covers.jpg" media-type="image/jpeg" />

    <spine toc="ncx">
    <itemref idref="a_1"/>
    <itemref idref="a_2"/>
    <itemref idref="a_3"/>
    <itemref idref="a_4"/>
    <itemref idref="a_5"/>
    <itemref idref="a_6"/>
    <itemref idref="a_7"/>

Comments are closed.