How to Convert HTML to Mobipocket for Kindle EReaders

01
of 06
Open Your HTML File in Calibre

Open Your HTML File in Calibre
Open Your HTML File in Calibre. Screen shot by J Kyrnin

When you decide to write an ebook and create a Mobipocket version of the book, the best place to start is with HTML. While you can convert Word documents and other file types to mobi, since Mobipocket is based off HTML, HTML is going to give you the cleanest files.

The easiest way to convert your HTML to mobi is with the program Calibre. You can get the program at their website http://calibre-ebook.com/. You can get Calibre for Windows, Macintosh, and Linux. It's free and easy to use. Calibre is primarily an ebook reader, but you can also use it to create and edit ebook files.

Open Your HTML in Calibre

Once you have Calibre open, you should click on the “Add books” button and browse to the HTML file of your book. Calibre will open it calling it the format “ZIP” which it obvously isn't, but don't worry about that.

On the next page I'll show you how to convert your HTML to the Mobi format.

02
of 06
Adjust the Meta Data of Your Book

Adjust the Meta Data of Your Book
Adjust the Meta Data of Your Book. Screen shot by J Kyrnin

Click on the “Convert books” button which opens the window displayed here. The first thing you should edit is the book meta data.

Because you've uploaded the book from HTML, chances are the meta data is wrong. It uses things like the file name for the title and so on. If your book doesn't have a publisher or you don't know what version it is, then just leave it blank.

Tips for the Meta Data Section

There are some features of Calibre that might not make sense at first.

  • “Author Sort” — This is the way the author name should be sorted. For example, in English most authors are sorted by last name, first name. But if the author is a corporation or some other form, the sorting style might be different.
  • “Tags” — These are just like any other tags, putting your book in a specific category.
  • “Series” and the version number — If the book is a part of a series, you can label that here, and you can also define the version number.

Don't Forget a Cover Image

The meta data for your book is important, as it keeps your book as correct as possible. And Calibre will save as much meta data as possible in each of the formats that you use. But the one thing you should not leave blank is the cover image. A cover image for your book is the first part of your marketing that book, and a good looking cover that includes the title and author(s) at minimum is how you'll get people to download and read your book. And buy it if you're selling it. Plus, the cover makes your book stand out in the Calibre application.

Choose or create an image in the JPEG format. You can also use PNG or GIF files, but I've found JPGs to be the most widely supported.

The next page will explain some of the other features you can modify in Calibre to adjust how your ebook publishes.

03
of 06
Clean Up the Look of Your Book Pages

Clean Up the Look of Your Book Pages
Clean Up the Look of Your Book Pages. Screen shot by J Kyrnin

Calibre gives you a lot of things you can adjust in your ebook. Next click on the “Look & Feel” tab. Here you can set things like the base font size, line height, character encoding, and even specify CSS to include with the file that might not have been in the original HTML.

You can leave most of these to the default for your first conversion. Then if you feel the fonts are too small or too large you can adjust them here. But there are a few items that I like to adjust:

  • I make sure the “Input character encoding” is set to the encoding I wrote the file in (usually utf-8).
  • I check “Remove spacing between paragraphs.” I can do this because I use the P element to separate my paragraphs. Calibre then adds an indent for each paragraph so that readers can tell where they start and end. This makes the text feel more like a book and less like a web page.
  • And I always “smarten punctuation.” This turns quotes, dashes, and elipses into their typographically correct equivalents.

Other Settings in Calibre

Most of the time, I leave the settings in the “Heuristic Processing,” “Page Setup,” “Structure Detection,” “Search & Replace,” and “Debug” as the defaults. But if you have issues with how your book is generated you can play with them.

  • Heuristic Processing scans your book for common problems to fix them. It's a very high-level correction that can cause more problems than it solves, but if your book has a lot of problems with how it's publishing, this may help.
  • The Page Setup tab sets defaults for how the book is published. I leave it as an output of Generic e-ink and an input of Default input profile.
  • Structure Detection lets you modify the XPath expression to find your sections or chapters. The default looks for H1 and elements that have the words “Chapter,” “Section,” “Part,” and a few others to define the different parts of your book.
  • Search & Replace lets you search across your document for a regular expression and replace it with something else. This is especially useful for making global changes, but I find it's better to make sure the HTML source file is corrected rather than doing it in Calibre.
  • The Debug panel lets you define a folder to store debug information about your book. You won't need this unless the book is not saving correctly and you need to see specifically where the problems are occurring.

The next page looks at the generation of the Table of Contents for your book.

04
of 06
Generate the Table of Contents

Generate the Table of Contents
Generate the Table of Contents. Screen shot by J Kyrnin

If your HTML file does not include a table of contents, you will need Calibre to generate one for you. Click on the “Table of Contents” tab to make sure that the generation is accurate.

If your book does not have a Table of Contents, you can force Calibre to generate one by clicking the “Force use of auto-generated Table of Contents.” Calibre will then save your book with the auto-generated table of contents.

On this panel you can also define the maximum number of links to appear in your table of contents, what the minimum number of chapters there should be to turn off the links, and even a filter to remove items from the table of contents such as Appendices or other extras. You can also use XPath to define the exact elements to be detected and placed in the table of contents.

The next page will get your file set up to save as a Mobi file for Kindle.

05
of 06
Convert Your Book to Mobi for Kindle

Convert Your Book to Mobi for Kindle
Convert Your Book to Mobi for Kindle. Screen shot by J Kyrnin

The first thing you need to do is go to the upper right corner of the Calibre window and make sure that your file format is “MOBI.” Then click on the “Mobi Output” panel and check the features that are specific to Mobi:

  • You can remove the generated table of contents here if your book has one built in.
  • If you're not removing the generated table of contents, then you should give it a title.
  • You can also place the generated table of contents at the beginning of the book, but this isn't recommended.
  • I don't recommend ignoring the margins unless they are causing problems.
  • And you can specify that the “author sort” style should be used for the author instead of the regular.
  • As I mentioned a few pages back, you can use image types other than JPEG, but they don't always work in older versions of the Kindle. So Calibre will convert all your images to JPEG for you. Of course, this can result in ugly images, so it's better to do the conversion to JPEG before you load your file into Calibre.
  • I also don't like to disable compression, as it can make your books really large.

Calibre will convert your file into the old style of MOBI, the new style, or both. But I recommend using these settings just for the old style of MOBI, this is more widely supported. You can convert it to AZW3 as well if you want to use the newer Kindle settings. Calibre will convert to that ebook format as well.

Finally, you can also change the tag marking that the book is to be filled with personal docs, and you can enable sharing by Facebook. I don't recommend changing the Personal Doc tag, and Facebook sharing is your own preference.

Once you're done with all the settings, click on the “OK” button. Calibre will then start building your book in the Mobi format.

The last page will show you how to view your book once it's saved.

06
of 06
View Your Book and Test the Settings

View Your Book and Test the Settings
View Your Book and Test the Settings. Screen shot by J Kyrnin

Once your book is in Calibre in the Mobi format you can use Calibre to read it and make sure it looks correct. Highlight the book and right click (or option-click on a Mac). Choose “View” and then ”View specific format.” Then choose the Mobi format from the list.

Calibre will open a new window and show you your book in the Mobi format.

But Don't Stop Testing There

It's best to test your book directly on a Kindle device. If you don't have one, borrow one from a friend. Just email the .mobi file you created with Calibre to the Kindle so you can see how it looks there. You can also upload the file with a USB cable to the Kindle.

If you don't have a Kindle, you can use the Kindle Previewer (for Mac and Windows) to test your files.