Sitemap

Walkthrough for Self-Published Authors: How To Write and Publish A Book Using Leanpub’s Git and GitHub Writing Mode

23 min readAug 17, 2021

Use Leanpub to Write a Book and Create Ebook Files Using Git and GitHub

It’s easy to create PDF, EPUB, and MOBI ebook files on Leanpub, using our Git and GitHub writing mode!

You can then self-publish your Leanpub-generated ebook files anywhere you like, including on Amazon KDP, Apple Books, Google Play, and elsewhere.

And of course, with just the click of a button, you can also publish your ebook any time on Leanpub’s bookstore, and start earning 80% royalties on every Leanpub sale!

Finally, you can also use Leanpub to create a Print-Ready PDF that you can upload to print-on-demand services, so you can get your book into print, too!

Getting Started

In this article, we’ll show you how to write your book using Leanpub and create ebook files from your manuscript, in just a few minutes!

We’ll also show you how you can publish your book on Leanpub’s bookstore, after adding a book cover image, a book description, and setting up your Leanpub author profile.

OK, here we go!

Creating Your Book’s GitHub Repository

The first thing you need to is create a repository for your book on GitHub.

To do this, go to https://github.com and sign in.

Click the green “New” button to the right of the list of repositories:

Press enter or click to view image in full size

This will take you to a page where you can set up a new repository for your Leanpub book:

Press enter or click to view image in full size

By default, “Public” will be selected. This means anyone can see your repository. Select “Private” if you don’t want anyone to be able to see your repository:

Press enter or click to view image in full size

Next, type a name for your repository:

Press enter or click to view image in full size

Scroll down and click the green “Create repository” button:

Press enter or click to view image in full size

This will take you to a “Quick setup” page:

Press enter or click to view image in full size

Click on the clipboard icon to copy the repository information:

Press enter or click to view image in full size

Go to the command line on your computer. In this tutorial we’re using a Mac, and we go to the command line by opening an application called “Terminal”:

Press enter or click to view image in full size

Go to the folder on your computer where you want to clone your GitHub repository. In this tutorial, that is a folder called “repos”:

Press enter or click to view image in full size

Type “git clone” and a space, and paste in the repository information you copied on GitHub:

Press enter or click to view image in full size

After a moment, you will see a message saying that the repository has been cloned:

Press enter or click to view image in full size

Alright, now that we’ve got our repository set up on GitHub and cloned on our computer, it’s time to create a new book on Leanpub!

Creating a Book in Leanpub’s Git and GitHub Writing Mode

Go to https://leanpub.com/create/book to create a book in GitHub writing mode:

Press enter or click to view image in full size

First, type a title for your book into the “TITLE” box. You can change your title later:

Press enter or click to view image in full size

Click in the “BOOK URL” box. Leanpub will automatically suggest a URL for your book’s web page on Leanpub. You can change this URL at any time:

Press enter or click to view image in full size

Scroll down and you will see “MAIN LANGUAGE USED IN YOUR BOOK.” You can select a language from the drop-down. Like the other settings, you can change this at any time:

Press enter or click to view image in full size

In the section below, you will be presented with various Writing Mode options:

Press enter or click to view image in full size

Select the “Cloud” option:

Press enter or click to view image in full size

In the section below, you will be presented with various Writing Mode options:

Press enter or click to view image in full size

For this tutorial, select “Using Git and GitHub”:

Press enter or click to view image in full size

Next, enter your GitHub username, followed by a forward slash / and your GitHub repo name, and the names of the branches you want to use on your repo when you preview and publish your book (“main” is entered by default):

Press enter or click to view image in full size

Next, scroll down, you will see the subscription plan options. By default, “Standard” will be selected, if you are setting up your first book in Leanpub.

Select a plan:

Press enter or click to view image in full size

Scroll down and, if you are not signed in to a Leanpub account, you will see an option to enter information to create a new account. You will also see an option to sign in, if you already have a Leanpub account:

Press enter or click to view image in full size

To create a new account, fill in the relevant information:

Press enter or click to view image in full size

If you selected a paid subscription, scroll down you’ll see a form for entering your payment information:

Press enter or click to view image in full size

Finally, tick the box if you wish to accept our Terms of Service and Privacy Policy, and click the blue button to finish creating your new book:

Press enter or click to view image in full size

If this is the first Leanpub book you have created, you will see a page that is asking you to verify your email address (unless you’re a course author, and you have already verified your email address that way):

Press enter or click to view image in full size

If you check your email, you should see a message from Leanpub with the subject line:

[Leanpub] Thanks for trying Leanpub! Please verify your email address…

The contents of the email will say:

In the email, click the link that says: “Click here to verify your email address.”

Getting Started

You will now be taken to the Getting Started page for your book:

Press enter or click to view image in full size

If you use bookmarks in your web browser, we recommend you bookmark this page in your web browser in a bookmark folder for your book, but this is not required.

(If you’d like to learn more about navigating around Leanpub as an author, please see this article.)

Adding Leanpub As A Collaborator on Your Book’s GitHub Repository

Go back to the GitHub page for your book’s GitHub repository:

Press enter or click to view image in full size

Click on “Settings” near the top right, to go to the “Settings” page for the repository:

Press enter or click to view image in full size

Click on “Manage Access” at the top of the menu on the left to go the page where you can add collaborators:

Press enter or click to view image in full size

At this point, you may be prompted to enter your password:

Press enter or click to view image in full size

Scroll down until you see the green “Invite a collaborator” button:

Press enter or click to view image in full size

Click the button and you will see a box where you can add a collaborator:

Press enter or click to view image in full size

Type “leanpub” in the search box, and elect the “Leanpub” option:

Press enter or click to view image in full size

With Leanpub selected, click “Add leanpub to this repository”:

Press enter or click to view image in full size

You will see that Leanpub has been invited to the repository:

Press enter or click to view image in full size

Your invitation will be accepted automatically in the next few minutes!

Adding Default Content to Your GitHub Repository

Next, you need to add some content to your GitHub repository. (Leanpub does not write to your GitHub repository.)

Next, click here to download the zip file with default content. This will download the default content to your computer.

You will now find the file wherever you store downloads on your computer.

Press enter or click to view image in full size

Double-click the folder to unzip it, and you will see the “manuscript” folder:

Copy the “manuscript” folder. Then, go to the cloned GitHub repository on your computer, and paste the “manuscript” folder into the repository.

Press enter or click to view image in full size

Next, copy the manuscript folder and paste it into your book’s repository on your computer:

Press enter or click to view image in full size

Go back to the command line on your computer and change to the GitHub repository for your book.

Press enter or click to view image in full size

Change into your book’s directory:

Press enter or click to view image in full size

Type git add . and hit Return:

Press enter or click to view image in full size

Type git commit -m "adding default manuscript folder" and hit Return. You will see messages indicating that the content has been committed.

Press enter or click to view image in full size

Type `git push` and hit Return to push the commit to the repository on GitHub.

Press enter or click to view image in full size

Please note we’re not going to post screenshots every time we commit and push in this tutorial! We just wanted to make sure to walk you through every step at least one time.

Creating a Preview

To create your first preview, using the default content we included in your new book, go back to the Getting Started page for your book:

Press enter or click to view image in full size

Next, click on the “Versions” link you’ll see in the horizontal menu at the top of the page:

Press enter or click to view image in full size

This will take you to the Preview page for your book:

Press enter or click to view image in full size

Scroll down until you see the blue “Create Preview” button:

Press enter or click to view image in full size

Now, click the “Create Preview” button. You will go to a page like this, where you will see a progress bar at the top:

Press enter or click to view image in full size

When the preview process is complete, you will see download links for the preview, in a variety of formats:

Press enter or click to view image in full size

Click the top link to download the PDF version:

Press enter or click to view image in full size

Scroll through the PDF to see what it looks like. Here’s a screenshot of the Table of Contents:

Press enter or click to view image in full size

The default content included in this book explains how this writing mode works.

Chapter One and Chapter Two are for people who want to write in plain text.

Chapter Three and Chapter Four are for people who want to write in Word.

We recommend you give the chapters you need a quick read, before moving on with this tutorial!

The rest of this tutorial is for people writing in plain text, not Word, but the principles are the same. We’ll make a separate tutorial for writing in Word sometime soon!

Writing in Your Book

Next, on your computer, go to the “manuscript” folder you downloaded earlier, and that you copied into your GitHub repo:

Press enter or click to view image in full size

If you have just created a new book from our default content, the `manuscript` folder will contain five files:

```
Book.txt
chapter1.txt
chapter2.txt
chapter3.docx

chapter4.docx

resources
```

How Book.txt Works

The top file is named “Book.txt”. This file is a list of the files that you want to be included in your book. Leanpub’s book generators use this file when they are generating new versions of your book, to decide what files to include in your book, and the order.

If you open the Book.txt, you will see this list of file names:

```
chapter1.txt
chapter2.txt
chapter3.docx

chapter4.docx

```

Press enter or click to view image in full size

This tutorial if for people who want to write in plain text. So, you can delete the lines that list the .docx files.

Delete the following lines from the Book.txt file:

```
chapter3.docx

chapter4.docx

```

The contents of your Book.txt file will now be:

```
chapter1.txt
chapter2.txt
```

Press enter or click to view image in full size

Make sure to save your changes, and then close the Book.txt file.

Next, you can delete the .docx files from your “manuscript” folder:

Press enter or click to view image in full size

The contents of your “manuscript” folder will now be:

Press enter or click to view image in full size

Writing In Your Book

To write in your book, open the file “chapter1.txt”. Currently, the file will have this content:

Press enter or click to view image in full size

To see how writing a Leanpub book in plain text works, let’s just select and delete everything in this file:

Press enter or click to view image in full size

Now, let’s start writing!

First, type “# Introduction” on the top line, to give the file a chapter heading:

Press enter or click to view image in full size

Next, just type something like this:

It’s *fun to write* books **that people will love!**

Press enter or click to view image in full size

When you generate the next preview of your book, the part of the sentence between single quotation marks, *fun to write*, will appear in italics, and the part of the sentence between double quotation marks, **that people will love!**, will appear in bold.

In your text editor, save your changes, and close the file.

Renaming a File and Updating Book.txt

Now, let’s rename the file we were working on.

You can name your files anything you want! Your file names will not be shown to readers.

Let’s go back to our “manuscript” folder:

Press enter or click to view image in full size

Right-click on the “chapter1.txt” file and select “Rename”:

Press enter or click to view image in full size

What you see exactly will depend on your computer, but you should see options like these!

Let’s rename this file “introduction.txt”:

Press enter or click to view image in full size

You will now see this in your “manuscript” folder:

Press enter or click to view image in full size

Now, remember that Book.txt file?

We need to edit the list of files in Book.txt, so Leanpub’s book generators will know to look for a file called “introduction.txt”, the next time we create preview!

Open the Book.txt file again:

Press enter or click to view image in full size

Delete the top line, and type “introduction.txt”:

Press enter or click to view image in full size

Deleting a File and Creating a New File

Next, let’s delete the chapter2.txt file from the “manuscript” folder”

Press enter or click to view image in full size

Delete the chapter2.txt file, and the contents of your “manuscript” folder will now look like this:

Press enter or click to view image in full size

Now, using your text editor, create a new text file and save it in your “manuscript” folder.. Let’s call it “chapter_one.txt”:

Press enter or click to view image in full size

To make sure this file appears in our next preview, open up the Book.txt file again:

Press enter or click to view image in full size

This is what you will see:

Delete the line “chapter2.txt” and replace it with “chapter_one.txt”:

Press enter or click to view image in full size

Next, make sure to save your changes and close the file.

All right, now Leanpub’s book generators will know what files to use, the next time we create a preview of our book!

Adding an Image to Your Book

All right, now let’s add an image to our new text file!

To add an image to your book, you’ll first want to add the image file to your book’s “resources” folder:

Press enter or click to view image in full size

If you look in the “resources” folder now, you’ll see there is a file there already, called “palm-trees.jpg”:

Press enter or click to view image in full size

If you looked through the whole PDF we downloaded earlier when we made our preview, you would have seen this image in Chapter Two:

Press enter or click to view image in full size

To add a new image to your book, copy and paste the image from your computer into your book’s “resources” folder.

In this example, we’re copying and pasting an image named “marm-and-tangie.png” into our book’s “resources” folder:

Press enter or click to view image in full size

Let’s add this image to the new file we created just a moment ago. Open the file “chapter_one.txt”:

Press enter or click to view image in full size

This file will be empty, because we haven’t written anything in it yet!

Press enter or click to view image in full size

Let’s type a new chapter heading and a sentence:

Press enter or click to view image in full size

Now, let’s add that image.

On a line by itself, type the following:

Press enter or click to view image in full size

The exclamation point ! at the start of the line tells Leanpub’s book generators to add an image here.

The part between the square brackets [ ] is the image caption; in this case, the caption will read “Marmalade and Tangerine”.

The part at the end between the parentheses ( ) is the file name of the image; in this case, the file name is “marm-and-tangie.jpg”.

All right, that’s how you add an image!

Committing and Pushing Your Changes

Next, you need to commit your changes and push them to GitHub.

On the command line, type `git commit -m “first tutorial steps”` and hit the Return key.

Next, type ‘git push’ and hit the Return key.

Creating a New Preview of Your Book

All right, now we’re ready to create a new preview of our book!

To create a new preview, go back to the preview page for your book on Leanpub:

Press enter or click to view image in full size

Scroll to the bottom of the page and click the “Create Preview” button again:

Press enter or click to view image in full size

When the preview completes, click the top link again to download the new PDF:

Press enter or click to view image in full size

Here’s what the introduction looks like:

Press enter or click to view image in full size

And here’s the page with our image:

Press enter or click to view image in full size

Creating a Sample Book

One last thing: if you publish your book on Leanpub, we have a feature that will generate a sample book automatically, for potential readers to download from your book’s web page on Leanpub, to help them decide if they want to buy your book.

To generate a sample book, you need to tell Leanpub’s book generators what files to include in the sample book.

Go to your book’s “manuscript” folder and open the “introduction.txt” file:

Press enter or click to view image in full size

Here is what you will see:

Press enter or click to view image in full size

On a line at the top of the file, type:

{sample: true}

Press enter or click to view image in full size

This tells Leanpub’s book generators to include this file in the sample book.

OK, that’s all it takes to make a sample book! Please make sure to save your changes and commit and push them.

Go back to the preview page for your book and click “Create Preview” one last time:

Press enter or click to view image in full size

You will now see that there are download links for the sample book, as well as the main book:

Press enter or click to view image in full size

Click the top link to download the PDF version of your sample book:

Press enter or click to view image in full size

Open the PDF and you will see that Chapter One appears in the Table of Contents, but if you go to Chapter One you will see this:

Press enter or click to view image in full size

This lets people see the whole Table of Contents for your book, but only shows people the sample content from the sample chapters you choose to include.

Publishing Your Ebook

When you’re happy with these preview ebook files, you’re ready to use them to self-publish your book anywhere you like online!

You can use a variety of self-publishing services, from Amazon KDP to Lulu to Smashwords in IngramSpark, amongst many others.

As we mentioned above, we also have a Print-Ready PDF export option, so with one click you can also generate the file you need to use a print-on-demand service, to self-publish your book in print.

If you want to customize your book’s colophon page (the page after the cover page) before publishing your book, please see this article.

Of course, we also recommend you publish your book here on Leanpub! Not only do we pay an 80% royalty rate on every sale, but we also have a number of features that are pretty unique, like the ability to create discount coupon links for your book.

(For a long-ish guide to what makes Leanpub somewhat unique in the world of self-publishing, please see this article.)

If you’d like to publish your book on Leanpub, you’ll want to add some information about your book and a cover image first. We’ll show you how to do that in the sections below.

Writing Your Book Description

To begin adding your book’s information, scroll up and click on “Settings” in the horizontal menu at the top of the page:

Press enter or click to view image in full size

By default, this will take you to the “About” page for your book, which is the top item in the vertical menu at the left:

Press enter or click to view image in full size

On this page, you can add your book’s subtitle, a description of your book that will be displayed in an “About the Book” section on your book’s Leanpub web page, some “Teaser” text, and a “Meta Description” for search engines.

Enter your information in each of the boxes:

Press enter or click to view image in full size

Finally, review your information and scroll to the bottom of the page and click the “Update Book” button:

Press enter or click to view image in full size

When the book is updated, you will briefly see a success message at the top of the page:

Press enter or click to view image in full size

Adding a Book Cover Image

Next, let’s add a cover image to our book, that will be displayed on the course’s web page and anywhere else the book is shown by Leanpub, such as bestseller or category lists, or on social media.

To upload your book cover image to Leanpub, click on “Book Cover” in the vertical menu to the left:

Press enter or click to view image in full size

This will take you to a page where you can upload an image for your book:

Press enter or click to view image in full size

Scroll down until you see the section called “How to Choose a Cover Size”:

Press enter or click to view image in full size

You will see there is a message saying that your book image should be 1800 pixels wide x 2700 pixels high, which is equivalent to, 6.0 inches wide x 9.0 inches high, or, in centimetres, 15.24 cm wide x 22.86 cm high. (This is the same cover size for all books uploaded using the Bring Your Own Book writing mode.)

Press enter or click to view image in full size

Creating a Book Cover Image

If you’ve never created a book cover image before, you may find the following articles helpful:

How To Make A Book Cover Image Using Keynote

http://help.leanpub.com/en/articles/5340489-how-to-make-a-book-cover-image-using-keynote

How To Make A Book Cover Image Using PowerPoint

http://help.leanpub.com/en/articles/5343361-how-to-make-a-book-cover-image-using-powerpoint

Here is a book cover we made following these instructions:

Press enter or click to view image in full size

[Editor’s Note: We’re using an image from Unsplash, which is a great resource for images you are free to use (though you should always check attribution requirements, of course!).]

Uploading Your Book Cover Image

When you’re ready to upload your book cover image, scroll down and click “Choose File”:

Press enter or click to view image in full size

Navigate on your computer to the image you want to use. What this looks like will depend on your operating system. Here’s what it looks like in a Mac:

Press enter or click to view image in full size

Click “Open” (or the equivalent button you see on your computer) to add the image as your course image:

Press enter or click to view image in full size

You will now see the image has been selected:

Press enter or click to view image in full size

Next, click the blue “Update Book Cover” button:

Press enter or click to view image in full size

This will generate a new preview of your book, which will take a few moments.

When the process completes (you may need to refresh your browser window), you will see your book cover appear at the top left:

Press enter or click to view image in full size

Pricing Your Book

Leanpub uses a “variable pricing” model for selling books, courses and bundles.

This model is very popular with Leanpub readers, who enjoy being able to decide what to pay, within the constraints set by you, the author.

Before you publish your book on Leanpub, you will want to set both the Minimum Price and Suggested Price for book.

To set the Minimum and Suggested prices for your book, click on “Store” in the horizontal menu at the top of the page:

Press enter or click to view image in full size

Next, click on “Pricing” in the vertical menu to the left:

Press enter or click to view image in full size

This will take you to the Pricing page for your book:

Press enter or click to view image in full size

For this example, we’re going to set the Minimum price to $9.99 and the suggested price to $14.99:

Press enter or click to view image in full size

[Editor’s Note: Pricing is notoriously hard, so we recommend experimenting with different price points over time, to see which prices work best for you and your audience. However, we would like to note that the most common mistake authors make when it comes to pricing, is selling themselves short, and setting the price too low!]

Next, scroll down until you see the “Maximum Leanpub Discount %” section:

Press enter or click to view image in full size

The wording in this section is hopefully self-explanatory, but basically, by setting a maximum discount percentage here, you are opting your book in to Leanpub discount sales, include our popular Weekly and Monthly discount sale newsletters.

We strongly recommend you opt in to these sales. People love getting discounts!

Choose the highest discount percentage you’re comfortable with. For this example, we’re choosing 50%:

Press enter or click to view image in full size

When you’ve made all your pricing choices here, click the blue “Update Pricing” button:

Press enter or click to view image in full size

Setting Up Your Author Profile

Next, if this is your first Leanpub book, you will want to set up your author profile page here:

https://leanpub.com/user_dashboard/settings

On that page you will see the various options we provide for setting up your author profile:

Press enter or click to view image in full size

We highly recommend you upload a nice picture of yourself and add your social media information, as well as a brief bio in the “About You” section. This really helps sell books!

After you add your information, make sure to click the “Save Settings” button at the bottom of the page:

Press enter or click to view image in full size

Here’s an example of what an author profile page looks like, after you set it up:

Press enter or click to view image in full size

Publishing Your Book on the Leanpub Bookstore

OK, now we’re ready to publish our book!

To publish your book, go back to the Versions section, by clicking the “Versions” tab in the menu at the top of the page:

Press enter or click to view image in full size

Next, click on “Publish New Version” in the menu to the left:

Press enter or click to view image in full size

This will take you to the “Publish” page for your book:

Press enter or click to view image in full size

Finally, scroll down and click the blue “Publish Book” button:

Press enter or click to view image in full size

When the publishing process has been completed, you will then see a message saying your book has been published:

Press enter or click to view image in full size

To go to your published book’s Leanpub web page, click on the book cover image at the top left:

Press enter or click to view image in full size

Congratulations! People can now buy your book on Leanpub from this page, where you’ll earn an 80% royalty on every sale:

Press enter or click to view image in full size

Notice that blue “Edit” button?

Press enter or click to view image in full size

The “Edit” button is only visible to you, and to any co-authors you may add to your book. Click it any time to go to your book’s “Overview” page:

Press enter or click to view image in full size

Here is what the book landing page will look like to a normal person, who is not the author (it’s the same, but with no “Edit” button):

Press enter or click to view image in full size

Updating Your Book

One last thing: Leanpub books are really easy to update.

To update your book, all you have to do is:

1. Edit your book file or files, save your changes, and commit and push.

2. Generate a new preview to make sure everything looks good.

3. Go to the “Publish New Version” page and click the “Publish Book” button.

Next Steps

Ok, that’s it!

As a next step, you may want to read this article about specific ways you can use Leanpub to sell your book.

To learn more about navigating around Leanpub as an author, please read this article.

If you have any questions, you may find answers instantly if you search our Help Center or our Authors Forum.

--

--

Leanpub
Leanpub

Written by Leanpub

Leanpub is the best way in the world to write, publish, and sell ebooks. Publish in-progress, serial and complete ebooks in PDF, EPUB and MOBI.

No responses yet