Creating An EPUB Book From Markdown
A quick and dirty guide to making an EPUB book from a set of Markdown files using pandoc.
In this example I have strarted a book with chapters and a cover image.
Prequisites
- some markdown files
- pandoc
Markdown File Structure
I have given the chapters numbered prefixes and added a cover image:
-rw-rw-r-- 1 ubuntu ubuntu 160 May 28 15:15 01-title.md
-rw-rw-r-- 1 ubuntu ubuntu 123 May 28 14:53 02-introduction.md
-rw-rw-r-- 1 ubuntu ubuntu 45307 May 28 15:17 cover.jpg
NB one can create subdirectories for specific sections if you want to include an images folder for use in that chapter - users of Hugo will be familiar with this.
The file 01-title.md contains important header information:
---
title: "My New Book"
author: "Author Name"
date: "2024-05-28"
lang: "en"
cover-image: "cover.jpg"
---
# Title Page
This is the title page of the book.
Note the cover-image reference.
Pandoc
Simple via apt-get:
sudo apt-get install pandoc
Find more info here.
Conversion
This command line will turn all markdown files in the current directory, include a table of contents, and output an EPUB file:
pandoc *.md --toc -o my-book.epub
Validation
One way to check the resulting EPUB file before deployment is to use this validator.
Deployment
Use any of the regular ways of sending files to your Kindle, eg email.
If you want to publish it as a book on the Amazon Store you'd need to proceed to Kindle Direct Publishing.