Publishing with GitBook
Pushing the Book to Git(Hub)
To use Git for versioning and collaboration, you need to initialize the book's directory as a Git repository and push it to GitHub or a repository on your server. To do this, switch to the my_book
directory and run the git init
command. Then, use the git remote add origin git@github.com:dmpop/my_book_repo.git
command to connect the local repository to the one on GitHub.
If you set up a Git repository on your own server, you should use the
git remote add origin ssh://user@remotehost/path/to/my_book_repo
command to add the remote host to the repository (replace user
with the actual username, remotehost
with the server's IP address or domain name, and path/to/my_book_repo
with the path to the remote repository). To add all files, commit the changes, and push everything to GitHub or your own repository, run the following commands:
git add -A git commit -m "Initial commit" git push origin master
You need to run these commands every time you want to commit and push changes to the repository. However, you can automate this process by adding the following function to the ~/.bashrc
file:
function gitc { git add -A HOSTNAME=$(hostname) git commit -m "$HOSTNAME" git push origin master }
The next time you commit and push changes, open the terminal, switch to the my_book
directory, and run the gitc
command. The function uses the machine's hostname as the commit message, which offers a convenient way of identifying the source of the latest commit (which is handy if you work on the book from different machines).
Once you've pushed the book to the GitHub repository, other contributors can review changes, create forks, and submit pull requests. You can also use Git to track changes and revert to previous versions, among other things. Even if you don't need this functionality for working on the book, you can use Git as a replacement for third-party file syncing services to keep the book project in sync on different machines.
Publishing the Book
When the book is ready, you can publish it on GitBook. Before you do this, however, you need to add a cover and connect the editor to the GitBook service. To do the former, choose Book | Set Cover Picture and select an image you want to use as a cover. The image must be in the JPEG format, and its dimensions should be 1800x2360.
To link the editor to the GitBook service, choose Book | Advanced Settings (Figure 5), enter your username and token in the appropriate fields, and press OK. Then, choose Book | Publish As, select the existing book item from the Book drop-down list, and specify the version number in the Version field. Hit OK to push the book to GitBook.
Once the book has been pushed to GitBook, the service builds an ebook in the supported formats. You can monitor the build process in the Activity section of the book page on GitBook (Figure 6).
The GitBook editor also lets you generate local copies of the book in different formats for distribution through other services and channels. Using the available build commands under the Book menu, you can output the book in the PDF, EPUB, and MOBI formats as well as generate a static website (Figure 7).
Alternative Markdown Editors
Because any GitBook-based book is just a set of Markdown-formatted, plain-text files, you can use any Markdown editor for working with the book. Of course, GitBook's own editor is still the best tool for the job, but in some situations, using it isn't an option. When you need to tweak a chapter on an Android device, you can use the excellent DroidEdit code editor [7] for editing and the SGit app [8] to pull and push changes. If you use GitHub for the book project, you might appreciate GitHub's own editor, which supports soft wrap and the Zen Mode for a distraction-free writing environment. Using the editor, you can edit the book right in your browser.
If GitHub's editor is not your cup of tea, you might want to give Prose [9] a try. This slick and lightweight Markdown text editor integrates nicely with GitHub. Once authorized, the editor gives you access to all your GitHub repositories. As a Markdown editor, Prose supports Markdown syntax highlighting, and the editor's interface features a toolbar that gives quick access to all basic formatting options (Figure 8).
Using the hosted version of Prose is the easiest way to start using the editor. However, the editor is released under an open source license, so you can grab the source code from the project's GitHub repository and deploy the software on your own server.
« Previous 1 2 3 Next »
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.
-
ZorinOS 17.1 Released, Includes Improved Windows App Support
If you need or desire to run Windows applications on Linux, there's one distribution intent on making that easier for you and its new release further improves that feature.
-
Linux Market Share Surpasses 4% for the First Time
Look out Windows and macOS, Linux is on the rise and has even topped ChromeOS to become the fourth most widely used OS around the globe.
-
KDE’s Plasma 6 Officially Available
KDE’s Plasma 6.0 "Megarelease" has happened, and it's brimming with new features, polish, and performance.
-
Latest Version of Tails Unleashed
Tails 6.0 is based on Debian 12 and includes GNOME 43.
-
KDE Announces New Slimbook V with Plenty of Power and KDE’s Plasma 6
If you're a fan of KDE Plasma, you'll be thrilled to hear they've announced a new Slimbook with an AMD CPU and the latest version of KDE Plasma desktop.
-
Monthly Sponsorship Includes Early Access to elementary OS 8
If you want to get a glimpse of what's in the pipeline for elementary OS 8, just set up a monthly sponsorship to help fund its continued existence.