Skip to content

How to create ebooks with Markdown

New Course Coming Soon:

Get Really Good at Git

My process for creating ebooks

I currently have 16 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!

Are you intimidated by Git? Can’t figure out merge vs rebase? Are you afraid of screwing up something any time you have to do something in Git? Do you rely on ChatGPT or random people’s answer on StackOverflow to fix your problems? Your coworkers are tired of explaining Git to you all the time? Git is something we all need to use, but few of us really master it. I created this course to improve your Git (and GitHub) knowledge at a radical level. A course that helps you feel less frustrated with Git. Launching Summer 2024. Join the waiting list!

Here is how can I help you: