In ebooks, you can link one piece of text to another piece of text. This is called a "crosslink".
For example, if you had a line like this in your book:
For more information on this topic, see Chapter 8.
...you could make "Chapter 8" be a link to the start of Chapter 8 in your ebook.
In the ebook, people would see "Chapter 8" was formatted differently from the text around it, and know that they can click on it to go to another part of the ebook.
In this article, we're going to show you how you can create crosslinks in your Leanpub ebook!
From the Markua Manual: Crosslinks and IDs
Creating an "Anchor"
Before you can point a link to something, you need to have something to point the link to!
The thing you point the link to is called an "anchor". You need to type the anchor in your book manuscript, but no one who reads the book will see the anchor.
Here's a normal chapter heading in a Leanpub book manuscript:
# Chapter 8
Here's the same chapter heading, but with an "anchor" attached to it:
{#chapter8}
# Chapter 8
The anchor in this example is:
{#chapter8}
The anchor can actually be anything you want, as long as it starts with a # and is surrounded by { and }.
So, you could also do this:
{#chaptereight}
# Chapter 8
If you want to attach an "anchor" to a specific word in a sentence, you attach the anchor to the end of the word, with no space in between, like this:
Dogs and cats{#cats} actually get along just fine!
In this case the "anchor" is:
{#cats}
Creating a Link to an "Anchor"
To create a link to an anchor, you surround the word or words you want to turn into a link with [ and ], and then you attach the anchor to that, between ( and ).
That may seem a little technical at first, but it will be second nature after a while!
Let's start with the example line from the beginning of this article:
For more information on this topic, see Chapter 8.
To make "Chapter 8" into a link, we do this:
For more information on this topic, see [Chapter 8](#chapter8).
The link in this example is:
[Chapter 8](#chapter8)
In the ebook, "Chapter 8" will be formatted as a clickable link.
Here's what it will typically look like in the ebook:
We also support "smart crosslinks". You can learn about smart crosslinks in the Markua spec here. There's also a Leanpub Authors Forum post about this here.
OK, that's it!
If you have any feedback or questions about this article, please email the Leanpub team about it at hello@leanpub.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!