Creating an eBook is a great way to share information with others. An eBook allows you to write and organize long-form content. You can then either give it away or charge for it.

Leanpub is a great platform that helps authors quickly create eBooks, publish them in multiple formats like PDF, EPUB and MOBI and charge them if you choose to do so.

If you've never written an eBook before, the process may seem daunting. In this article, you'll learn how to publish an eBook on the Leanpub platform written in Markdown and stored in a GitHub repository.

As of this writing, I've written two eBooks on Leanpub with another one on the way. I hope to share some shortcuts to the Leanpub docs in this blog post to expedite understanding of how Leanpub handles eBooks.

By the end of this article, you'll be able to take what you've learned and have an eBook ready for distribution to your interested readers!

Setting the Stage

There is a lot to authoring an eBook from writing, editing and publishing. This article isn't going to be about writing an eBook. I'm going to assume you already have some content written or have an idea of the type of content you'd like to write.

We're going to focus on the logistics of what it takes to publish an eBook on the LeanPub platform. To narrow focus, you're going to learn how to write your eBook in Markdown and how to use GitHub as a repository for your eBook content.

I'll assume you have have a Leanpub and GitHub account created.

LeanPub eBook Authoring Options

When you create an eBook on Leanpub, you've got a few options on how to write the eBook.

  1. Google Docs
  2. Plaintext files
  3. In-browser

Each method has its own benefits and drawbacks. In this article, we're going to cover writing your eBook in "plaintext" mode. When Leanpub mentions "plaintext", they're talking about Markdown.

I personally prefer to write my eBooks in Markdown. The simplicity, structure and speed of Markdown parsing is unparalleled. In this article, we're going to be focusing on writing your eBook in Markdown.

If you're not familiar with MarkDown (more specifically Markua), I highly recommend checking out The Markua Manual.

Set up Your GitHub Repo

When authoring an eBook in Markdown hosted on GitHub, you'll need to create a private GitHub repository. It doesn't matter what name it's called. If you have other repos, I like to preface my eBooks with eBook- to indicate the repo is for an eBook.

Creating a LeanPub eBook GitHub Repository

Add LeanPub as a GitHub Collaborator

Once the repo is created, you'll need to give Leanpub access to your private repo. To do that, click on Settings in your repo and then on Collaborators.

Once on the Collaborators screen, add the leanpub username as a collaborator as shown below.

That's it for creating the GitHub repo.

Add Initial Markdown Files to Your Repo

When publishing eBooks with Leanpub using Markdown/GitHub, each chapter is a separate Markdown file. These Markdown files will be the majority of the files that will exist in your GitHub repo. But there are some other metadata files you'll need to add along with some optional ones I personally recommend.

Add Required Leanpub Files

To allow Leanpub to understand the structure of your eBook, you must add a few files in a specific path.

You'll first need to create a directory inside of your repo called manuscript. This is where everything will be placed. Inside of the manuscript directory, you'll need to create two files called book.txt and sample.txt.

Technically, the only required file is book.txt, I highly recommend adding sample chapters in the sample.txt file. This is the file that contains all of the chapters you're giving away if you plan to charge for the eBook.

Book.txt

The book.txt file is the only required file that defines the order of your chapters. Like the sample.txt file, book.txt is simply a list of Markdown files each on a new line.

Below you will find a screenshot of what The Pester Book eBook's book.txt file looks like. You can see there are many different Markdown file references in here. None of these Markdown files are required by Leanpub. They are all of the files that make up my eBook in chapter form.

Leanpub book.txt example

Sample.txt

The sample.txt file will contain Markdown file names of all of the content that will be made available when a potential reader clicks on Read Free Sample on the book's main page.

Leanpub eBook Sample

For example, below are the sample Markdown files I am sharing for The Pester Book defined in sample.txt.

The content you share in sample.txt is completely up to you.

Although book.txt is technically the only required file to show up in your GitHub repo, there are a few files I personally recommend adding to every eBook.

At this point, these Markdown files are only placeholders. They are templates for you to populate later.

About-the-author.md

In this Markdown file, I provide some information about myself and how to contact me. Here's a template I use:

**Adam Bertram** is a 20-year veteran of IT and experienced online business professional. He’s an entrepreneur, IT influencer, Microsoft MVP, blogger at [adamtheautomator.com](https://adamtheautomator.com/blog), trainer and content marketing writer for multiple technology companies. Adam is also the founder of the popular IT career development platform TechSnips. Catch up on Adam’s articles at adamtheautomator.com, connect on [LinkedIn](https://LinkedIn.com/in/AdamBertram) or follow him on [Twitter](https://twitter.com/adbertram).
Sample about-the-author.md

About-this-book.md

This is the file where I introduce the concept of the Leanpub eBook. In this file is where I attempt to quell piracy as much as possible.

This is the ‘Forever Edition’ on [LeanPub](http://leanpub.com/). That means when the book is published as it’s written and may see periodic updates.

If you purchased this book, thank you. Know that writing a book like this takes hundreds of hours of effort, during which I’m not making any other income. Your purchase price is important to keeping a roof over my family’s heads and food on my table. I’m not rich–this income is important to us. Please treat your copy of the book as your own personal copy–it isn’t to be uploaded anywhere, and you aren’t meant to give copies to other people. I’ve made sure to provide a DRM-free file (excepting any DRM added by a bookseller other than LeanPub) so that you can use your copy any way that’s convenient for you. I appreciate your respecting my rights and not making unauthorized copies of this work.

---

If you got this book for free from someplace, know that you are making it difficult for me to write books. When I can’t make even a small amount of money from my books, I’m encouraged to stop writing them. If you find this book useful, I would greatly appreciate you purchasing a copy from LeanPub.com or another bookseller. When you do, you’ll be letting me know that books like this are useful to you, and that you want people like me to continue creating them.

-Adam
Sample about-this-book.md

feedback.md

The feedback.md file is where I provide instructions to the reader on how they can submit feedback to me.

I’d love your feedback. Found a typo? Discovered a code bug? Have a content suggestion? Wish I’d answered a particular question? Let me know.

1. Please have a chapter name, heading reference, and a brief snippet of text for me to reference. I can’t easily use page numbers, because my source documents don’t have any.
2. Go to [my blog](https://adamtheautomator.com) to email me to let me know.

Thank you for taking the time to help make this book better!

release-notes.md

The release-notes.md file is where I summarize changes I've made through the history of the eBook. Since the Leanpub model is all about constant iteration and releasing before the book is finished, it's important to let readers know what's changed since the last update.

Your format can be anything but I like to add a date and then a few bullets under the date. You can see an example of my Building a PowerShell Tool eBook below.

08/12/19
 - fixed refactoring chapters from showing up in ToC
 - added second refactoring chapter
 - added YouTube video

07/23/19
 - Initial book setup

Creating the eBook on Leanpub

Once you've added all of the required and one or more of the recommended files, you can now create the eBook on Leanpub.

Start by logging into leanpub.com and starting the book creation process. This is where you will fill in all of the required information.

If you're publishing your eBook via GitHub, be sure to select In plain text on your computer and Using Git and GitHub.

When you choose Using Git and GitHub, you'll be prompted to provide the GitHub repo name. Leave the branch to master.

Note: Be sure to include your GitHub username followed by the repo name like adbertram/myfirstebook.

Setting eBook Options

At this point, your eBook is created on Leanpub but you're far from being done. Leanpub allows you to set a plethora of options around your book such as setting up a web page, defining the price, setting rendering options and more.

All of these options are far outside of the scope of this article. Take a look at the animated GIF below to see all of the options you have at your disposal.

Adding Chapters

Here's where you're going to spend 95% of your time; actually writing your book! You'll be adding chapters (Markdown files) in your GitHub manuscript directory and adding them to book.txt like crazy here!

This section is short because it will vary considerably for everyone. Add as many chapters (Markdown files) as you'd like and order them with the book.txt file.

Add the eBook Cover

An important step in finalizing your eBook is creating a cover. You can find the section to upload an eBook cover under Settings --> Upload Book Cover.

Upload Book Cover

According to Leanpub:

Your book page size (set on this page) is 6.0 inches wide x 9.0 inches high. The page size of your book determines the size of cover you need to upload.

Please upload a cover image with the following dimensions: 1800 pixels wide x 2700 pixels high

The cover image formats we support are PNG and JPEG.

I don't have a creative bone in my body so I usually try to find a free eBook cover on Snappa and modify the template to my liking.

Preview your eBook

Once you've built out your book as you see fit, the next step is previewing it. When you preview your eBook, Leanpub reads the Markdown files from GitHub and collates them into a PDF, MOBI and EPUB formats.

Leanpub follows all of the options you have set in in the Setting eBook Options as well. You'll find the first time you preview your book, it's going to look off. You'll more than likely have to fool around with the options and understand how Leanpub reads your Markdown to make it look how you'd like.

To create a preview of your eBook, log into the author dashboard and go to Preview or Publish --> Preview New Version. Once here, click on Full Preview and then on the Create Preview button. This will render your eBook and allow you to download it.

Publish your eBook

Once you've made changed and tweaked your eBook to your heart's content, it's time to publish!

In your author dashboard, click on Preview or Publish --> Publish New Version. You'll then get an option to provide release notes. These are the release notes I add to the release-notes.md file. Always provide release notes to let your readers know what's changed.

Write, Release, Repeat!

You now should have everything you need to get started with your first eBook on Leanpub. Now get to writing and publishing!