Skip to content

How to create ebooks with Markdown

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!


→ I wrote 17 books to help you become a better developer:

  • C Handbook
  • Command Line Handbook
  • CSS Handbook
  • Express Handbook
  • Git Cheat Sheet
  • Go Handbook
  • HTML Handbook
  • JS Handbook
  • Laravel Handbook
  • Next.js Handbook
  • Node.js Handbook
  • PHP Handbook
  • Python Handbook
  • React Handbook
  • SQL Handbook
  • Svelte Handbook
  • Swift Handbook
...download them all now!

Also, JOIN MY CODING BOOTCAMP, an amazing cohort course that will be a huge step up in your coding career - covering React, Next.js - next edition February 2025

Bootcamp 2025

Join the waiting list