How to create ebooks with Markdown

My process for creating ebooks

I currently have 15 free books which I share, free of charge, to anyone that subscribes to my email newsletter.

Some of those books are at their 2nd edition (the ones on JavaScript and React) as tech moves fast and we must keep up.

The first one is from 2018.

In the near future I want to reorganize my free ebooks collection by revisiting a few of them, and maybe even adding new ones.

I had to set up again my book creation workflow on my Mac since I last updated to the wonderful 2021 MacBook Pro 14", so I took the opportunity to write about it.

I use a tool called honkit.

It’s a fork of another tool that was called gitbook, which I’ve been using before but has been deprecated and abandonware for a long time now, and does not work any more.

honkit works great. It is a free utility for creating a book using Markdown, and generate a PDF/ePub/Mobi version of it.

I can update a book and with a single command I can upload it to my website and let CloudFlare distribute it.

As far as I know, this is the simplest tool ever available capable of generating all those book versions.

Some other tools exist but don’t have all those capabilities.

Here’s how to get started.

Create a folder, and inside it add a book.json file

{
  "author": "Your name",
  "title": "The book title"
}

Create a cover.jpg vertical image that’s used for the cover. Add a cover_small.jpg if you want to make an ePub / Mobi version too.

Create a SUMMARY.md file with the ToC:

# Summary

- [Preface](README.md)
- [First chapter](content/1-first.md)
- [Second chapter](content/2-second.md)

Now add a README.md file, that’s the markdown file for the preface.

Add a content/1-first.md, that’s the markdown file for the first chapter.

And so on.

Now download Calibre and install it (or use Homebrew (brew install --cask calibre on macOS).

Then run:

npx honkit pdf  ./ ./book.pdf
npx honkit epub ./ ./book.epub
npx honkit mobi ./ ./book.mobi

that’s it, the book in PDF, ePub and Mobi (Kindle) will show up in the folder!

Download my free Programming Ebooks!