Weekend Project: Write and Publish eBooks on Linux with Sigil

426

Calling all writers — do you have a book you want to publish as an eBook? Ready to self-publish? Maybe you just want to provide some documentation in EPUB formats? Whether you want to publish prose, poems, or help the world RTFM, Sigil can help tame the text and massage it into the industry standard EPUB format.

What’s Sigil? It’s a What You See Is What You Get (WYSIWYG) ebook editor that’s open source (GPLv3) and runs on Linux. Which makes it perfect for our needs.

Getting Sigil

Sigil is not packaged for most Linux distros yet, but has binary installers for 32-bit and 64-bit Linux. As of this writing, you’ll find stable releases (0.3.4) and release candidates for 0.4.0. I’m running a release candidate, and it seems to be fine. You’ll also find the code as a zip file, and Mac and Windows packages as well.

After downloading the binary installer, simply make it executable (chmod +x filename) and then run ./Sigil-XXX-Linux-Setup.bin where XXX is the version number. Note that the 64-bit file name includes an x64 as well. One thing that I noticed when I ran the installer is that the fonts look really ugly. I was worried that this meant that the entire application was going to have Ugly Font Issues. Nope — just the installer, so breathe easy.

The installer does not require administrative/root privileges — it will happily install into your home directory, so I advise that unless you have a real need to make it available system-wide.

Understanding EPUB

Before we get started with Sigil, let’s talk about EPUB for a second. EPUB is a standard that defines how eBooks are to be packaged, presented, and delivered. The content of an EPUB eBook is (basically) XHTML, so if you’re familiar with HTML, the code Sigil shows will look very familiar to you. EPUB also uses CSS for style, and tops that off with a couple of files — the Open Packaging Format (OPF) and Navigation Center Extended (NCX) — that define the structure of the book.

All of the content and structure goodness is bundled up in a Zip file that may or may not be encrypted in some way. See the EPUB Overview in Sigil’s documentation if you’re looking for a more in-depth explanation.

If all of that sounds confusing, I have good news — Sigil does almost all of this for you automatically.

Working with Sigil

Sigil WindowLet’s fire up Sigil and take a look. If you accept the defaults, it will install Sigil in $HOME/sigil. Just cd to that directory and run ./sigil. It has a three-pane interface on startup, with content in the middle and “Book Browser” and “Table of Contents” panes on the sides. The browser shows all of the files that make up the book. If you start Sigil without a book in progress, it will have a placeholder file for content and the files content.opf and toc.ncx that correspond with the OPF and NCX mentioned earlier. Unless you have a good reason, you don’t need to work with either of those — Sigil will handle everything.

Since I didn’t have time to write a book before writing the article (not another one, anyway), I decided to see if I could cheat by importing HTML. Guess what? It worked like a charm. I imported the HTML from my review of Fedora 15 from a few days ago. We don’t use a lot of markup for Linux.com content — heading, paragraph, code, anchor, and a few other elements.

So, if you’re like me and prefer to edit HTML — you can likely write your entire book in HTML and then import it into Sigil. The best plan if you want to do that is to put each chapter or section in its own file — so chapter one would be its own file, chapter two would be its own file, and so on. Then when you create a book in Sigil you can simply go to the Text folder in the browser, right-click and select “Add Existing Item.”

Sigil will import plain text, HTML, and EPUB. For image support, you can use SVG, PNG, and JPEG. Note that the image import tool is pretty primitive — if you want to assign text to figures, you’ll probably need to do that manually at the moment.

Luckily, that’s no problem — you can use Sigil to see a side-by-side view of the WYSIWYG editor and the code editor.

I won’t spend a lot of time describing the Sigil WYSIWYG controls — they’re self-explanatory. Let it suffice to say that you have the essential formatting/markup options you need for most standard books. If you have a need for complicated equations and such, the things that LaTeX excels at for instance, then you may want to create those as images and import them rather than trying to do the markup in Sigil. In short, if you’ve used a word processor, you can use Sigil to write or mark up your content. If you haven’t used a word processor, you’re probably not going to be writing a book.

One thing I do want to call out is Sigil’s Meta Editor. This allows you to add the “meta” information to your book — things like the title, author, language, publisher, and so on. Hit F8 or go to Tools -> Meta Editor. This will bring up a dialog that allows you to define the basic metadata you need, and expanded metadata if you want.

What metadata do you need? At a bare minimum, you’ll need the language and title of the work. How do you know? Sigil validates the EPUB content when you use the Validate EPUB tool (hit Ctrl-Shift-v or go to Tools -> Validate Epub.

You may also want to massage the table of contents. Sigil will automatically generate a TOC from the headers in your documents, but if you want to do have every heading in the TOC or if you want different titles in the TOC you can edit them using the TOC editor. Note that the editor seems to have disappeared from the RC build, but should re-appear before the final release.

Converting to Mobipocket or Other Formats

If you want to provide content to someone with a Kindle or another book reader, or if you’d like to publish your book as a PDF, you will need to use another tool to covert from EPUB. The best tool to use for this is Calibre.

Calibre is a great desktop eBook reader and converter. It’s also very useful for checking your book while it’s in process — use Calibre to read the book while you’re editing it to make sure that the actual output from Sigil reflects what you’re seeing in Sigil.

To convert in Calibre, open the EPUB book and then right-click on the book in your library. Select Convert Individually and then change the Output Format (on the right-hand side) to the format you want. Calibre supports a ton of formats — some of which I’ve never even heard of! It will easily handle PDF and Mobipocket, though.

Sigil is still in early development — but it’s already awesome. I would love to see Sigil support ODF import and export Mobipocket on its own, but it’s a great tool for those of us with an interest in publishing eBooks using open source tools on Linux. Now you’re on the road to publishing your first eBook. As always, the writing is the hardest part — so get cracking!