Understanding Hyperlink Paths: The Path to TranquilityDoes the prospect of building hyperlinks have you bouncing off the walls with hyperactivity? Try to remain calm and Zen-like. Deep breath and hold for fivethis is vital stuff! Hyperlinks are very important in web design. Without them, the World Wide Web would be a pretty boring place. After all, remember what the web is: a bunch of pages and sites that are all interconnected. You've probably been surfing the web for a while now, so the concept of a link should make sense. The whole idea is click here, go there. In other words, you click a link, and it takes you somewhere else. This means that a hyperlink has two parts: what the visitor clicks (the link's starting point), and where the visitor is taken (the link's destination). For a hyperlink to work, both the starting point and the destination must be in place. Dreamweaver makes inserting hyperlinks into your pages easy, but they can be tough to troubleshoot when they don't work properly. So before you really get going with hyperlinks, it's critical to understand how they work. Otherwise, you may find yourself with a site full of broken links and a gaggle of frustrated web surfers pounding on your front door. Broken links just scream amateur, so be careful. A hyperlink has two parts: what the visitor clicks (the link's starting point), and where the visitor is taken (the link's destination). The first thing you need to know is that there are different types of hyperlink paths. Think of paths as providing directions from one location to another. If you're in New York City and want to get to Berkeley, California, you follow a specific set of directions to get there. Similarly, you follow a specific route through your site's structure when you link from your index file to your services file, for example. But just as when you travel from the Atlantic coast to the Pacific you can take interstate highways or local roads, when you build links you can choose from three types of pathsabsolute paths, document-relative paths, and root-relative pathsdepending on where you're linking to and the type of link you want to create. Geek's Delight
Absolute PathsHow's your Zen state coming along? I miss the sugar, too. Let's make this quick so we can go raid the junk-food stash. You can think of absolute paths as "hard" paths, because the entire destination is specified in the path. For example, http://www.tentonbooks/dw/paths is an absolute path. See how the whole URL is specified? Whenever you're linking to another site, or to a page in another site, you must be sure to use an absolute path. You can also use absolute paths when linking to pages within your own site, although it means more work with no major advantage. Here's a real-world example. If you were in New York City and wanted to visit Peachpit Press in Berkeley, you'd need Peachpit's full address, 1249 Eighth Street, Berkeley, California (send your Geoff Blake hate mail thereplease, no live animals). If you were missing part of the address, then you wouldn't know where to go. For example, if you had only the 1249 Eighth Street part, then you'd be lost. It's the same with absolute paths. If an absolute path is missing part of the URL, your link won't work because it won't know where to go. Imminent Doom
Document-Relative PathsDocument-relative paths can be considered "soft" paths. Links that use document-relative paths don't include the full URL, but only the path that leads the current file to the linked file. For example, let's say that your site includes a folder called. Inside this folder, you have two files, news and services. Because the two files reside in the same folder, when linking from one to the other, you can just link directly to the file name and leave out the part of the URL that is common to both files. So if you were linking from news to services, your link would simply read services. (You could use an absolute pathin which case your link would appear as http://www.yoursite.com/servicesbut that's kinda overkill, as most of the URL is common to both files.) Let's go back to our Peachpit example. If I were giving you directions from your house to Peachpit and you already lived in Berkeley, I wouldn't have to tell you to travel from New York City to Berkeley, Californiayou're already there. Instead, I'd leave out the part of the directions that were common between New York City and your home address and Peachpit's address, and just tell you what you need to know: "Go to 1249 Eighth Street." Make sense? Noteworthy
Root-Relative PathsChapter 4 when you first defined your site. |