Formatting Your eBook: Customizing & Editing Your Book’s HTML (Step 2)
In most cases, you will be able to skip this step. The only reasons you’d need to edit your book’s HTML is if you (1) want to add a Linked Table of Contents (TOC) or (2) want to embed images, such as fancy chapter titles that you can’t get with default fonts.
Before you edit your HTML at all, back up your file. Never edit the source without having a backup in case you make a mistake.
Fair warning: this can get a little complicated and won’t look pretty. If you just want a basic book and don’t need a linked TOC, I’d recommend skipping to the next lesson (converting your book). However, if you are massively stubborn (like me) and want to learn so that your book is beautiful and flawless, carry on.
Click here to jump to the lesson:
Embedding an Image | Creating a Linked TOC.
Embedding an Image
This is something I personally haven’t tried yet, but that I will be trying in the future. In lieu of a walk through, then, I’d like to recommend a great formatting series by Guido Henkel. He covers this in pretty through detail.
There are also some great tips on creating “enhanced books” over at eBook Architects.
Creating a Linked TOC.
Most of you clicked the link up there to jump down to this header, and that’s exactly what you’re going to be doing when you create a linked TOC: you’re building a list (the table of contents) that will enable the reader to choose from the list and automatically jump down to the chapter in question.
Some conversion software programs will automatically make your TOC for you. I’ve never made this work, as stubborn as I’ve been and as hard as I’ve tried. Thus, I came up with another approach. It’s the same technique I used in the mini TOC at the top of this post, but you insert it in your book.
This method of “jumping around” in a single document is called using a “name attribute.” It’s a two-part edit that you’ll have to do for each chapter title. Here are the two parts:
The link, or what readers will click to jump down to the chapter. This goes in the table of contents.
The “name” tag, which is the thing you’re referencing. This goes wherever you’re jumping to, so it’ll go in the code by the actual chapter.
Important Note: each name tag that you associate with a chapter will need to be unique so that clicking on Chapter 1 doesn’t accidentally reference both Chapter 1 and Chapter, say 20. An easy way to do this is to make a standard name tag format and run with it.
What I do is make each tag the abbreviation for the chapter. So Chapter 1 is “ch1″ and Chapter 2 is “ch2″ and so on. I make the Epilogue “eplg” and the synopsis, which I put at the beginning of my books, #snyps.Get the idea?
So let’s start with the first chapter.
When you first open your HTML (remember, right click on the file and choose to open with Notepad), you’ll see a bunch of messy formatting stuff at the beginning. You can ignore that. Instead, hit ctrl+f (or go to Edit>Find) to open a search dialog. Then, search for chapter 1.
First, this will take you down to the TOC entry for chapter 1. Let’s do a before and after to keep things simple.
Before:
[image error]
After:
[image error]
That up there is the link, and has to be exact, right down to the spaces. This will make the words “Chapter 1:” linkable in the TOC, since that’s what’s within the link tags. When readers click this, they will jump down to the name attribute that you’re about to make in the next step.
Important note: don’t type this in Word and then copy it into Notepad, since Word will sometimes do fancy things to the quotations formatting, and that will mess up your formatting and pretty much blow the code to pieces. Figuratively.
The next step is to write the name attribute into the code. So pull up your find box again and search for the second instance of “Chapter 1″ which should be your actual chapter heading in the book’s body.
This HTML will look something like this:
Before:
[image error]
It will be different depending on your personal font and formatting choices, but most conversions will render this code irrelevant. The important part is the bit that says “Chapter 1.” Now, you need to add the name attribute, like this:
After:
[image error]
Look closely. The only difference is the tag. This makes the title an anchor, which means the link from the TOC will now jump down to this bit of text.
Congratulations! You now know how to create a single entry in a linked TOC. Now, you have to repeat that for any chapter heading or bonus material (dedication, copyright, etc) that you want the TOC to jump to. It’s time consuming, but the end result is nice. Just remember to be patient with it as you go along.
Once you finish the entire thing, save and close your HTML. You’ll be able to right click the file again, knowing that it’s the most current, and open it in your browser. Do this and test all of the links to make sure that they take you to the appropriate place. Once you’re sure they do, you’re ready to convert your files.
I learned most of my HTML knowledge through the free lessons on w3Schools.com, and this is no different. If you want to see the page that taught me these basics, you can head here. They’re generic to HTML code, though, and not specifically to eBooks.
I think that’s more than enough for today. Tomorrow, I’ll have more on picking your conversion software and preparing to do the conversion.
The Full Formatting Bootcamp Syllabus:
Creating Your Source File
Customizing & Editing Your Book’s HTML
Finding a Conversion Software & Converting Your Book
Uploading Your Book for Sale