How to create an eBook from Markdown using Ibis?

Created February 4, 2021

Introduction

A few months ago I wrote an open-source eBook on how to get started with Bash Scripting.

This is when I came across a tool called Ibis created by Mohamed Said who is a Developer at Laravel.

Ibis allows you to generate an awesome PDF for your eBook, and you can just use markdown!

In this tutorial, I will show you how to get started with Ibis and write that eBook that you have always been planning to write!

Prerequisites

You need to have Composer installed, if you don't have it yet, you can follow the steps here:

How to install Composer

Installation

In order to install Ibis, all that you need to do is run the following composer command:

composer global require themsaid/ibis

After the installation, you can test if the ibis command is available with the following:

ibis -V

Once you are sure that you have the Ibis command line tool installed, you can instantiate a new project with the following command:

ibis init

Note: Make sure to run the command in an empty directory where you would store your Markdown files later on

The init command will generate the following files:

/assets
/assets/fonts
/assets/cover.jpg
/assets/theme-light.html
/assets/theme-dark.html
/content
/ibis.php

You can modify the /assets/theme-light.html and the /assets/theme-dark.html to change any of the styles for the eBook. For example, I like to increase the size of the text and the line spacing a little bit.

Configuration

In order to configure ibis all that you need to do is change the values in the ibis.php file.

The main settings would be:

Creating a cover photo

There is an awesome tool that you could use for free to generate your cover photo:

If you ever need to create a graphic, poster, invitation, logo, presentation – or anything that looks good — give Canva a go!

To change the cover photo, just substitute the default /assets/cover.jpg with your image!

Markdown files

With the above, you can then start writing your eBook! The content would be stored in the content folder where you will have to add your Markdown files.

Ibis would read all of the .md files in the content folder and would use all h1 titles as the name of the chapters.

If you are not familiar with Markdown, make sure to check out this guide here.

Building the PDF

Once you have your content ready, in order to build the PDF of your eBook, just use the following commands

ibis build
ibis build dark

If you want to generate a sample of your eBook use the following commands:

ibis sample
ibis sample dark

Once you run the command, it will generate your PDF and store them in the export folder.

The output that you will see would look like this:

==> Preparing Export Directory ...
==> Parsing Markdown ...
==> Adding Book Cover ...
==> Building PDF ...
==> Writing PDF To Disk ...

✨✨ 34 PDF pages ✨✨

Book Built Successfully!

Conclusion

If you like the Ibis tool, make sure to star it on GitHub and contribute!

If you publish your own eBook make sure to let me know by tagging me on Twitter @bobbyiliev_!

Hope that this helps!