Links5:28 with Wade Christensen
We couldn't move around the Web without links. We'll explore a few different ways to format links in Markdown, so you can add links throughout any Markdown document you write.
Starter code for this video:
When writing documents for the web, it is pretty hard to avoid links to other sites, 0:00 other pages, or even spots within the same page. 0:04 Markdown provides a syntax for writing links that is easy to remember and 0:07 feels natural. 0:11 Let's add a heading for this section. 0:12 Now to add a link, 0:16 you would first type what you want to appear on the page inside square brackets. 0:18 Then immediately following those square brackets, 0:22 you would add the link URL inside parenthesis. 0:24 So for example if I wanna link to Treehouse, I would type square brackets 0:28 and then I want word Treehouse to appear on the page, so that's what I type inside. 0:32 Then immediately following this closing square bracket, I'll type parenthesis and 0:37 the URL that I wanna link to inside those parentheses. 0:43 In this case, that'll be teamtreehouse.com and that's it. 0:46 This simplicity allows me to focus on my writing rather 0:52 than on how to link to something. 0:55 If we scroll down in the preview, you can see that we have a link to treehouse. 0:57 If I click it, It'll take me to the page, perfect. 1:01 You also have the option to provide a title, 1:07 which appears when you hover the mouse cursor over the link. 1:09 You just type a space after the URL and close the title inside quotes. 1:12 Both the url and the title should be inside parentheses. 1:17 So let's create another link to Treehouse. 1:20 So that you can see what I'm talking about. 1:23 So Treehouse quotes, the URL, so nothing is changed so far. 1:26 Now, after the URL, I'll type the space and 1:36 then I want to remain inside this closing parenthesis and 1:39 then I'll type my quotes and the title. 1:44 Now if I scroll down in the preview and hover over the first link, 1:52 you can tell it's a link, but nothing else happens. 1:56 If I scroll over the second link, we see our title up here link to Treehouse. 2:00 If I click on it it'll still take me to Treehouse. 2:05 Let's come back to our document. 2:08 Now what if I want to link to a reference at the bottom of a section or 2:12 a page like a footnote? 2:16 You start with the text in square brackets, but 2:18 you don't add the parenthesis. 2:20 Instead, you add a number to reference in another set of square brackets. 2:22 So I would start with square brackets and let's link to treehouse again, 2:26 so I'll call this treehouse and then outside the square brackets, 2:31 another set of square brackets and then a number to reference. 2:36 Because this is the first reference link we've used in this document, 2:39 I'll type the number one. 2:43 And now, at another place in the document, 2:43 I would type square brackets and the number that I'm trying to reference. 2:48 In this case it would be one and then I would type a colon 2:54 immediately outside my closing bracket, a space and the URL that I wanna link to. 3:01 And again this is just going to be the treehouse URL. 3:07 Now you may have noticed there are no parentheses here. 3:15 A reference link does not require parenthesis but it still works. 3:18 However just so you don't feel limited we can add a title to a reference link. 3:24 You would type a space and again we're not gonna add parenthesis anywhere. 3:28 But we will add the quotes and our title. 3:32 Now if we scroll down in our preview, we have all three links. 3:40 And you can see link to Treehouse, reference link to Treehouse. 3:46 If we click on it, same behavior. 3:51 Remembering how to write a link in Markdown can be a little tough at first, 3:56 but after you've written a few links, it'll feel natural. 4:00 Even if it doesn't, you'll have this handy Markdown reference document to remind you. 4:03 WIth our new linking power let's go up to our block quote and 4:08 make John Gruber's name a link to his website. 4:10 I think that would be nice. 4:13 Then we can call this video a wrap. 4:14 So let's go find that block quote Of our list section, there we go. 4:16 Now I want John Gruber's name to continue appearing on the page. 4:25 I want it to be clickable, so of course that goes on square brackets. 4:27 And then a URL to his websites, inside parenthesis. 4:35 I happen to have a linked to his page on Markdown, so I'll paste that in here. 4:40 and then it would be nice for him to have a title as well. 4:46 So space, quotes, and how about something meaningful like, 4:48 Creator of Markdown. 4:52 Alright now, let's go over to our preview, find that block quote. 4:56 There it is, so we can John Gruber's name is a link. 5:03 We've got our title, Creator of Markdown. 5:07 If I click on it, it takes us to his page. 5:09 All right, great. 5:12 So come back to our document. 5:12 We'll add a horizontal rule here. 5:17 And call this video a wrap. 5:22 I will see you in the next one where we talk about images. 5:24
You need to sign up for Treehouse in order to download course files.Sign up