Markdown link syntax
John Gruber’s Markdown is a great way to add simple mark-up to documents. The syntax is very easy to learn, unobstrusive when viewed in a text editor, and it maps directly to HTML. There’s a lot of third party support in terms of editor plug-ins and parsing libraries for many languages. This document was originally drafted in Markdown, before conversion to HTML via Jekyll.
Creating links in Markdown uses a combination of text, square brackets []
and parentheses ()
. They can be combined in three ways:
-
Inline - wrap the link text in square brackets and follow it with the target URL in parentheses.
Embed your [link text](#) and its url anywhere in the document.
-
Reference - wrap the link text as before, then provide an id in a second set of square brackets. Later in the document, define the link using the reference, a colon and the URL
In a run of text, [this will be a link][to]. And then, usually at the foot of the document, add the reference. [to]: http://goesnowheredoesnothing.com
-
“Short reference” - for when it makes sense for link text and reference id to be the same, single word. As before, use two sets of square brackets, but this time, the second set is left empty.
Again, embed the link [text][] and empty reference in the body of teh document, and dereference it later on. [text]: http://goesnowheredoesnothing.com
I use this version surprisingly often (and yet keep forgetting how to write it).
The full Markdown syntax can be found here. There are also two popular extensions to the language, MultiMarkdown and Github Flavoured Markdown.