Getting Ready For NaNoWriMo 2016 - Step 4: Nitty-Gritty Steps

Here is where things get really nerdy!

As I mentioned in previous sections writing in Markdown is pretty easy and requires very little in the way of actual coding or additional work. You're free to just write the way you normally would using Markdown style codes to create the kind of formatting you need in whatever text editor suits you. The biggest exception to that is when dealing with chapter titles and creating a table of contents. These tasks go hand-in-hand, so I'm going to talk about them together.

Each chapter gets a title that consists of two pieces: a code which determines the size of its font once it is turned into HTML (and then an eBook) and a another piece of code that gives it an identifying tag that I can use in the table of contents. If you are familiar with HTML we are giving each title a Header code and an Anchor.

In Markdown you can assign a Header tag to text using a series of number signs or hashtags equal to the level of Header importance you intend to use. To create a Header Level One you use one # (in HTML it is <H1>), a Header Level Two uses ## (<H2>), and so on. For the purposes of creating an eBook, I've decided that <H3> is ideal, so I put ### in front of every chapter title, like this:

### Chapter One

Please note that this isn't the only way to create Headers in Markdown, but for the purposes of eBook design this gives you the most flexibility with regards to your available header sizes.

In addition to the size/header code I also want to provide an anchor point that my TOC will use. That sounds complicated, but all we're really doing is creating an invisible stopping point that you can point to in other places within your book so that readers can jump to it quickly and easily. Since this will all become HTML this is literally the same thing as setting up a hyperlink within your document that a reader can click to navigate to another spot in your book.

To create an anchor point you need to use the code <a name="something"> replacing "something" with a unique identifier that you can reference later. This identifier can literally be anything from "chapterone" or "1" or "myintroductorychapter" or even "omgi'mthebestwriterever" but it needs to be unique enough that you can point a link to it later. This is all invisible to the reader, so it can be anything you want and you don't have to worry about being embarrassed by it later. I'm pretty boring so I tend to use the number of whatever chapter I'm writing. Consistency here is great, because if you know what you usually do, you won't have to scroll around to find your anchors later on.

After you've created your <a name="something"> code you'll type the actual text for your chapter title, then you'll need to end it with </a>. This piece (the anchors) is actually HTML code. There doesn't seem to be a good, consistent Markdown tool for this, so we're writing HTML code to accomplish what we need to do. HTML and Markdown go together like peanut butter and chocolate, so this is fine. You can have both of these types of codes together and it doesn't cause any problems. The thing to remember is that HTML and Markdown are pretty literal, so you'll need to get all of this exactly right, but don't let that scare you. It's actually pretty easy.

Here is the code for the first chapter in one of my books:

### <a name="One">Chapter One</a>

Pretty simple, right? The chapters following this will look very similar, so the code for Chapters Two, Three, and Four would look like:

### <a name="Two">Chapter Two</a>
### <a name="Three">Chapter Three</a>
### <a name="Four">Chapter Four</a>

Even as large of a nerd as I am, I'm not able to remember this precise code, so I just copy and paste that first chapter header over and over again, changing the "One" to a "Two," then "Three," and so on. This way, I only need to get it right once, and if I copy and paste that first, correct code, I can be pretty certain I'll do it correctly moving forward.

If you get all of that right, creating a working Table of Contents is super easy and just requires you to make a list of hyperlinks to those anchors you've created. That sounds complicated, but you've already done the hard part.

In Markdown a hyperlink is made up of two pieces, the text that is displayed and can be clicked, and the link that takes you to the anchor you have already set up. On the web this is a little more complicated, because you're dealing with longer URLs, but since this is an eBook you only need the anchor you've created.

To make this work you put your text in-between brackets like this: [Twenty]. In this case the word "Twenty" will appear and will function as your hyperlink. You'll need to follow that with the anchor name, surrounded by parenthesis like this: (#Twenty) That number symbol is key as that is the part that says, "Hey, this is a link!"

Put together, this little bit of code looks like:

[Twenty](#Twenty)

In your eBook it will just look like the following, but will be a working hyperlink:

Twenty

When you click the word "Twenty" you'll jump to wherever you placed the anchor "Twenty." Ideally, that will be at the start of Chapter Twenty where you put the code <a id="Twenty">Chapter Twenty</a>. Easy, right?

I like to make my Table of Contents a bullet list, so I put a bullet code before my hyperlinks. In Markdown you can do this using an asterisks, a plus, or a dash. I prefer a plus, so my code in my Table of Contents looks like this:

+ [Twenty](#Twenty)
+ [Twenty-One](#Twenty-One)
+ [Twenty-Two](#Twenty-Two)

And renders in my eBooks like this:

Your Table of Contents will need an anchor code so that your reader's Kindle can find it as well. This is very easy and requires you to use the same code you've just mastered. You'll need to use the anchor "TOC" because that's what Amazon's devices/software will be looking for, so it will look like this:

### <a name="TOC">Table of Contents</a>

If you were feeling really ambitious and/or lazy you could create a template file for yourself that contains all of this code, then just enter your fantastic new book into the template with everything else already set-up for you.

Not only are you a best-selling, highly-respected indie writer, but you're also a coding nerd. Congratulations!