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!
download all my books for free
- javascript handbook
- typescript handbook
- css handbook
- node.js handbook
- astro handbook
- html handbook
- next.js pages router handbook
- alpine.js handbook
- htmx handbook
- react handbook
- sql handbook
- git cheat sheet
- laravel handbook
- express handbook
- swift handbook
- go handbook
- php handbook
- python handbook
- cli handbook
- c handbook
subscribe to my newsletter to get them
Terms: by subscribing to the newsletter you agree the following terms and conditions and privacy policy. The aim of the newsletter is to keep you up to date about new tutorials, new book releases or courses organized by Flavio. If you wish to unsubscribe from the newsletter, you can click the unsubscribe link that's present at the bottom of each email, anytime. I will not communicate/spread/publish or otherwise give away your address. Your email address is the only personal information collected, and it's only collected for the primary purpose of keeping you informed through the newsletter. It's stored in a secure server based in the EU. You can contact Flavio by emailing flavio@flaviocopes.com. These terms and conditions are governed by the laws in force in Italy and you unconditionally submit to the jurisdiction of the courts of Italy.