Header image for Ahab!


A feeble attempt to help those foolish enough to make a Kindle book by hand


So you wanna publish a Kindle book on Amazon?

Ahab! is a simple template for producing Kindle specific .mobi files.
Available on github.com/cmod/ahab/.


I spent a few weeks reformatting and publishing four of my longer essays on the Kindle Direct Publishing platform. The process was a hodge-podge of snippets and trial and error. I wish I had this template from the start. Now I do. So I hope it helps you. (Disclaimer: I am by no means a .mobi wizard, which is why it’s on github β€” hack away and please suggest changes!)

This is all β€” clearly β€” a bit geeky. It’s for those of us who like to hand-code websites. Who want to know what’s going on under the hood. Who are obsessive about CSS class names and indent technique and derive pleasure from knowing that the innards of the machines they produce are as beautiful and effecient as possible.1


Mobi is Kindle’s ebook format. It’s sort of like epub’s step-brother. With a properly formatted .mobi file you can publish on the Kindle Direct Publishing platform.

#Why .mobi?

Pareto pricinple (80/20 rule). I want to leverage existing marketplaces for digital publishing, and Amazon covers 80%+ of the market I’m interested in reaching. iBooks just doesn’t have the audience, nor is the platform presently inviting (IMO) from a systems and ubiquity perspective. Kindle hits iPad, iPhone, Android, web, desktop … EVERYWHERE. And it does seamless syncing. I like all that. Readers like all that.

There's other engaged and energized communities emerging around products like Readmill but I don't want to have to deal with selling stuff on my own. And I do want to sell stuff. That's part of the experiment. And, I think it behooves anyone interested in the future of publishing to know the biggest guy in the room really well, even if you don't like them. (I've got nothing against Amazon but it seems like a lot of other folks do.)

This template

This template is meant to get you from thinking about publishing a piece of text you have to actually publishing it on Kindle Direct Publishing. If you have a long-form blog post composed mainly of text, I suspect you could convert it to a proper .mobi file using this template in fifteen minutes. Obviously, more complex texts (and cover production, etc) take more time.

So, this template is mainly about minimizing friction.


Yes β€” you're correct! You have to use a COMMAND LINE PROGRAM to make .mobi files for Kindle Previewer to preview them.

At the risk of this file turning into a horribly complex tutorial, after you install Kindlegen, open your Terminal program (assuming OS X), type "kindlegen content.opf" from inside the ahab directory and Kindle Previewer should be able to open the content.mobi file it spits out.

Kindle Previewer is pretty kludgy, but it gets the job done. It saves you from trying to send .mobi files to seven different devices. And speeds up development / testing / iteration time.

You will, at some point, want to send something to a bunch of Kindles. This utility is useful for that:


So Amazon revised their cover guidelines in early 2012. Here's the latest:

Here are the base requirements:

Requirements for the size of your cover art:

  • Minimum of 1000 pixels on the longest side
  • Ideal height/width ratio of 1.6

For better quality, we recommend that images be 2500 pixels on the longest side.

The 1.6 ratio bit is weird. It's the dimensions for the Kindle Fire. It is doubly awkward because hardware eink Kindles have a screen ratio closer to 1.3.

Amazon currently doesn’t offer the ability to include multiple, device specific covers. I feel most comfortable designing for hardware Kindles since I’m still not convinced anyone actually uses/reads on Kindle Fires. 2

For some reason, .png is not allowed for cover images. So make sure you stick with .jpg or .tiff.

Though .pngs are allowed elsewhere in a .mobi file.


Kindle Format 8 supports CSS media queries. It seems a little bit out of the scope of a baseline template, but if you're interested, Liz Castro explains all.

@font-face rules only work on Kindle Fire.

Actually, a lot of css rules only work on Fire. Floats, for example. The simpler you keep your CSS, the saner you'll be.

Here's the full list of KF8 HTML and CSS support:

What are these other files?

toc.ncx and content.opf are the two slightly alien files of this collection.

OPF means "Open Page Format". From Wikipedia:

The OPF file, traditionally named content.opf houses the EPUB book's metadata, file manifest, and linear reading order. This file has a root element package and four child elements: metadata, manifest, spine, and guide. All of these except guide are required. Furthermore, the package node must have the unique-identifier attribute. The .opf file's mimetype is application/oebps-package+xml.

The .ncx file is explained thusly:

The NCX file (Navigation Control file for XML), traditionally named toc.ncx, contains the hierarchical table of contents for the EPUB file. The specification for NCX was developed for Digital Talking Book (DTB), is maintained by the DAISY Consortium, and is not a part of the EPUB specification. The NCX file has a mimetype of application/x-dtbncx+xml.

Exciting stuff! *zzzzzz*

I've done my best to obviate thinking too much about those files.


So you have your cover. You have your properly formated .mobi. You've tested it in Kindle Previewer and it looks pretty good on all devices. Now, how do you publish?

You can just mail the .mobi file to friends, put it up on a server, upload it to a forum β€” distribute any way β€” and any Kindle will be able to open the file.

But if you want to "publish" it on Amazon β€” set prices and get it properly listed β€” then Kindle Direct Publishing is what you want. It should be pretty self explainatory.


This is by no means exhaustive. It's meant to give anyone interested in .mobi a little boost. I've tried to strip away all the unnecessary gunk. What's remaining should be relatively self explanatory.

Similar projects


If you do end up publishing something with this, please let me know. Post about it in the github project or shoot me@craigmod.com an email.


  1. Apparently, rumor has it, you can just upload a Word document and Kindle Direct Publishing will magically make it into a .mobi file. I haven’t dared try that. I can’t imagine what chaos might emerge. So, this sort of template is for those of us who are grossed out β€” who feel it in their gut β€” by the idea of auto-converting word documents. Heck, it’s for those of us who are grossed out by Word documents in general. ↩︎

  2. I’m sure there’s tons of happy Kindle Fire owners, but β€” like the original Kindle β€” Amazon usually ships a very rough, nearly beta version one. So I still consider this first Fire iteration a public beta. I’m sure it’s going to get a lot better. The current hardware eink Kindles are dreams compared to the first retro-inspired Kindle. (Which is pretty awesome in it’s own special way, but not nearly as portable, simple as the current crop.) ↩︎

Subscribe to my newsletters

Join some ~30,000 other subscribers.

Roden: photography Γ— literature Γ— tech Γ— film (monthly)
Ridgeline: walking Γ— Japan (weekly)

Always one-click to unsubscribe.

Popular Essays