Building a Book for Kindle and Nook

I’m thinking about self-publishing my novel, Of Fish and Swimming Swords, on Kindle and other ebook readers.  Today, I want to talk a little about the process I’m using to build the book as I do final edits and formatting.

The easiest way to build a book for Kindle and have a good chance that it will look like what you want is to create a MobiPocket file.  Amazon makes available all of the tools you need to create one of these files.  I use a Mac, so if you use either a Mac or a Linux/UNIX system, you should be okay.  I’m not sure how things work on Windows.

Ingredients you need to get:

  • kindlegen, a program you can get from Amazon

Ingredients already on your Mac or Linux/UNIX system:

  • make

I’ll also assume that you unpacked the kindlegen download into your home directory and that the kindlegen program is found at /Users/your-username/kindlegen/kindlegen.

Creating the Workspace

When I’m working on a novel, I have everything I need in a single directory.  It helps me keep organized and makes it easy for me to make a backup of the novel without having to tease the files out from everything else on my computer.  We’ll call this directory the ‘workspace directory.’

In the workspace directory, I have my chapters, usually with one chapter per file by this point.  For right now, let’s have them be HTML files named ch1.html, ch2.html, etc.  I use sequential numbers for a reason we’ll see later.  If you are only going to be working in HTML, then the numbers aren’t as important.  You’ll also want to put here the HTML version of the front of your novel as well as the various special files that are needed to build an e-book, such as the OPF and NCX files.

I also have a ‘graphics’ sub-directory with my any graphics in the e-book.  It helps keep the final versions separate from any works in progress I might have lying around in the work directory.  For this example, we’ll have ‘graphics/cover.jpg’ be the cover of the book.

Building the Kindle e-Book

Finally, we need to create what’s called a ‘Makefile‘.  This is the file that tells make how to build everything.  It’ll start out fairly simple, but we’ll add some optional parts once we finish building the Kindle e-book.

In your favorite editor, create the following file in the workspace directory and name it ‘Makefile’.

N.B.: The line after should begin with a tab, not eight spaces.

Make sure that KINDLEGEN_PATH points to the directory holding the kindlegen program. HTML_CHAPTERS should be a list of all of your chapters. OPF is the name of your opf file describing the contents of your e-book, and NCX is the name of your ncx file describing the navigation in your e-book. The kindlegen package from Amazon contains examples of each of these special files.  Finally, the file pointed to by FRONT is the material in your e-book that comes before your first chapter, such as the table of contents or copyright notice.

The KINDLEGEN_FLAGS are not set to anything right now.  Once you’re ready for the final version of your e-book, go ahead and remove the hash (#) from the first KINDLEGEN_FLAGS line and add it to the second.  This uncomments the first and comments out the second.  The ‘-c2’ flag tells kindlegen to compress the e-book as much as possible.

Once you have everything set in the Makefile, you can run the following command to build your e-book:

make mobi

This will look at all of the files in the book: the chapters, the front, the OPF and NCX files, and the cover art.  If any of these files are newer than the existing file, or the file doesn’t exist, then the file will be built using the kindlegen command.  If you want your e-book to be a different file name, change ‘’ to the name you want everywhere you see ‘’ (should be two places).

Creating Other Formats

So we’re producing an e-book that works on the Kindle.  How do we make the other formats, such as an e-pub for Nook?  The easiest way is to use Calibre, an open source program that lets you change e-books from one format to another.


I’ll assume that you install Calibre in the default /Applications folder on the Mac.  If you’re using Linux or UNIX, you’ll probably know which bits you need to change.

In the Makefile, you’ll want to add a few lines so it looks something like the following.  I’ve included the earlier Makefile as I presented it here so you’ll have some context for the additions.

Of course, you can change novel.epub to anything you like as long as it’s changed the same way everywhere.

You can now create an e-book for the Nook by running the following command:

make epub

It works just like the ‘make mobi’ command.  If anything has changed in the HTML files, then it will first build the Kindle version and then convert the Kindle version to the ePub for the Nook.

That’s it.  You can now go back to tweaking your chapters, front material, or even cover art and not have to worry about some complex process for creating a new copy of your e-book.  In an upcoming post, I’ll talk about what I needed to do to get a PDF for POD publishing.

Enhanced by Zemanta

Published by


James is a software developer and self-published author. He received his B.S. in Math and Physics and his M.A. in English from Texas A&M University. After spending almost two decades in academia, he now works in the Washington, DC, start up world.

4 thoughts on “Building a Book for Kindle and Nook”

  1. Thanks for this! When you "create a directory" are you using the word "directory" interchangeably with "folder" or are you saying to set up a "workspace directory?" If the latter, "how" do I do that on my mac?

    Awesome :) very helpful post.

    1. For me, "directory" and "folder" are interchangeable, so feel free to read "folder" when I say "directory" and you should be okay.

  2. It seems that I must use HTML first before going on. Do you think it is necessary to use HTML5?

    Thank you very much

    1. HTML5 will probably be the cleanest option, but it isn't that much different from prior versions of HTML as far as ebook reading texts are concerned. Paragraphs are still paragraphs. If you are looking at adding active content to an ebook, though, then you should plan on using HTML5.

Comments are closed.