Use Leanpub to Write a Book and Create Ebook Files Using Git and GitHub
It's easy to create an ebook on Leanpub using our Git and GitHub writing mode!
Related Article: Getting Started Using Leanpub's Git and GitHub Writing Mode to Write a Book: TL;DR Version http://help.leanpub.com/en/articles/4868811-getting-started-using-leanpub-s-git-and-github-writing-mode-to-write-a-book-tl-dr-version
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!
(Already familiar with GitHub? You may prefer this TL;DR tutorial.)
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.
(Shortcut! You can follow the detailed instructions below to create a brand new repository, but you can also skip a lot of steps if you're already familiar with GitHub and you use this template.)
Click the green "New" button to the right of the list of repositories:
This will take you to a page where you can set up a new repository for your Leanpub book:
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:
Next, type a name for your repository:
Scroll down and click the green "Create repository" button:
This will take you to a "Quick setup" page:
Click on the clipboard icon to copy the repository information:
Cloning Your Book's Repository Onto Your Computer
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":
Go to the folder on your computer where you want to clone your GitHub repository. In this tutorial, that is a folder called "repos":
Type "git clone" and a space, and paste in the repository information you copied on GitHub:
After a moment, you will see a message saying that the repository has been cloned:
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:
First, type a title for your book into the "TITLE" box. You can change your title later:
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:
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:
In the section below, you will be presented with various Writing Mode options:
Select the "Cloud" option:
In the section below, you will be presented with various Cloud writing mode options:
For this tutorial, select "Using Git and GitHub":
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):
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:
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:
To create a new account, fill in the relevant information:
If you selected a paid subscription, scroll down you'll see a form for entering your payment information:
Verifying Your Email Address
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):
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."
You will now be taken to the Getting Started page for your book:
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:
Click on "Settings" near the top right, to go to the "Settings" page for the repository:
Click on "Manage Access" at the top of the menu on the left to go the page where you can add collaborators:
At this point, you may be prompted to enter your password:
Scroll down until you see the green "Invite a collaborator" button:
Click the button and you will see a box where you can add a collaborator:
Type "leanpub" in the search box, and elect the "Leanpub" option:
With Leanpub selected, click "Add leanpub to this repository":
You will see that Leanpub has been invited to the repository:
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.
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 top level of the repository:
Go back to the command line on your computer:
Change into your book's directory:
git add . and hit Return:
git commit -m "adding default manuscript folder" and hit Return. You will see messages indicating that the content has been committed.
Type `git push` and hit Return to push the commit to the repository on GitHub.
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:
Next, click on the "Versions" tab you’ll see in the horizontal menu at the top of the page:
This will take you to the Preview page for your book:
Scroll down and click the blue "Create Preview" button:
You will go to a page like this, where you will see a progress bar at the top:
When the preview process is complete, you will see download links for the preview, in a variety of formats:
Click the top link to download the PDF version:
Scroll through the PDF to see what it looks like. Here's a screenshot of the Table of Contents:
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:
If you have just created a new book from our default content, the `manuscript` folder will contain five files:
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:
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:
The contents of your Book.txt file will now be:
Make sure to save your changes, and then close the Book.txt file.
Next, you can delete the .docx files from your "manuscript" folder:
The contents of your "manuscript" folder will now be:
Writing In Your Book
To write in your book, open the file "chapter1.txt". Currently, the file will have this content:
To see how writing a Leanpub book in plain text works, let's just select and delete everything in this file:
Now, let's start writing!
First, type "# Introduction" on the top line, to give the file a chapter heading:
Next, just type something like this:
It's *fun to write* books **that people will love!**
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:
Right-click on the "chapter1.txt" file and select "Rename":
What you see exactly will depend on your computer, but you should see options like these!
Let's rename this file "introduction.txt":
You will now see this in your "manuscript" folder:
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:
Delete the top line, and type "introduction.txt":
Deleting a File and Creating a New File
Next, let's delete the chapter2.txt file from the "manuscript" folder"
Delete the chapter2.txt file, and the contents of your "manuscript" folder will now look like this:
Now, using your text editor, create a new text file and save it in your "manuscript" folder. Let's call it "chapter_one.txt":
To make sure this file appears in our next preview, open up the Book.txt file again:
This is what you will see:
Delete the line "chapter2.txt" and replace it with "chapter_one.txt":
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:
If you look in the "resources" folder now, you'll see there is a file there already, called "palm-trees.jpg":
If you looked through the whole PDF we downloaded earlier when we made our preview, you would have seen this image in Chapter Two:
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.jpg" into our book's "resources" folder:
Let's add this image to the new file we created just a moment ago. Open the file "chapter_one.txt":
This file will be empty, because we haven't written anything in it yet!
Let's type a new chapter heading and a sentence:
Now, let's add that image.
On a line by itself, type something the following, but using your image's file name:
![Marmalade and Tangerine](marm-and-tangie.jpg)
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:
Scroll to the bottom of the page and click the "Create Preview" button again:
When the preview completes, click the top link again to download the new PDF:
Here's what the introduction looks like:
And here's the page with our image:
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:
Here is what you will see:
On a line at the top of the file, type:
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:
You will now see that there are download links for the sample book, as well as the main book:
Click the top link to download the PDF version of your sample book:
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:
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:
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:
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:
Finally, review your information and scroll to the bottom of the page and click the "Update Book" button:
When the book is updated, you will briefly see a success message at the top of the page:
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:
This will take you to a page where you can upload an image for your book:
Scroll down until you see the section called "How to Choose a Cover 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 Upload writing mode.)
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
How To Make A Book Cover Image Using PowerPoint
Here is a book cover we made following these instructions:
[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":
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:
Click "Open" (or the equivalent button you see on your computer) to add the image as your course image:
You will now see the image has been selected:
Next, click the blue "Update Book Cover" button:
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:
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:
Next, click on "Pricing" in the vertical menu to the left:
This will take you to the Pricing page for your book:
For this example, we're going to set the Minimum price to $9.99 and the suggested price to $14.99:
[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:
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%:
When you've made all your pricing choices here, click the blue "Update Pricing" button:
Setting Up Your Author Profile
Next, if this is your first Leanpub book, you will want to set up your author profile page here:
On that page you will see the various options we provide for setting up your author profile:
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:
Here's an example of what an author profile page looks like, after you set it up:
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:
Next, click on "Publish New Version" in the menu to the left:
This will take you to the "Publish" page for your book:
Finally, scroll down and click the blue "Publish Book" button:
When the publishing process has been completed, you will then see a message saying your book has been published:
To go to your published book's Leanpub web page, click on the book cover image at the top left:
Congratulations! People can now buy your book on Leanpub from this page, where you'll earn an 80% royalty on every sale:
Notice that blue "Edit" button?
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:
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):
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.
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.
If you have any feedback or questions about this article, please email the Leanpub team about it at email@example.com!
If you have any questions or thoughts on writing and self-publishing with Leanpub, please join our global community of authors in our Authors Forum here!
Are you interested in self-publishing, and creating your first Leanpub book? Here are some quick tutorials for our most popular writing modes: http://help.leanpub.com/en/articles/3088382-quick-walkthroughs-for-getting-started-on-a-leanpub-book
Are you looking for great deals on Leanpub ebooks, ebook bundles, and courses? Sign up for our Weekly and Monthly newsletter sales here!
Subscribe to our YouTube channel here: https://www.youtube.com/leanpub
Please subscribe to our YouTube channel here: https://www.youtube.com/leanpub
You can also follow Leanpub in lots of other places!