ABSOLUTE PATH NAMES
You can also specify the link to another page on your local system by using an absolute pathname.
Absolute pathnames point to files based on their absolute locations on the file system. Whereas relative pathnames point to the page to which you want to link by describing its location relative to the current page, absolute pathnames point to the page by starting at the top level of your directory hierarchy and working downward through all the intervening directories to reach the file.
Absolute path names always begin with a slash, which is the way they’re differentiated from relative pathnames. Following the slash are all directories in the path from the top level to the file you are linking.
NOTE
To has different meanings, depending only how you’re publishing your HTML files. If you’re just linking to files on your local disk, the top is the top of your file system (/on UNIX, or the disk name on a Macintosh or PC). When you’re publishing files using a web server, the top is the directory where the files served by the web server are stored, commonly Referred to as the document root., you’ll learn more about absolute pathnames and web servers in Lesson 18, “putting your site Online.”
Table 5.2 shows some examples of absolute pathnames and what they mean.
TABLE 5.2 absolute path names
path name
|
means
|
Href=”/u1/1emay /file.html”
|
File. Html is located in the directory /u1/1emay (typically on UNIX systems).
|
Href=”d/files/html/file.htm”
|
File, htm is located on the D: disk in the directories files/html (on DOS systems).
|
Href=”hard%20disk%201/html files/file.html”
|
File.html is located is located on the disk hard disk 1, in the folder HTML files (typically on Macintosh systems).
|
USING RELATIVE OR ABSOLUTE PATHNAMES?
The answer to that question is, “it depends,”. If you have a set of files that link only to other files within that set, using relative pathnames makes sense. On the other hand, if the links in your files point to files that aren’t within the same hierarchy, you probably want to use absolute links. Generally, a mix of the two types of links makes the most sense for complex sites.
I can explain this better with an example. Let’s say that your site consists of two sections, stuff and things. If you want to line from the file index. Html in /stuff to history. Html in/stuff (or any other file in /stuff), you use a relative link. That way, you can move the /stuff directory around without breaking any of the internal links. On the other band, if you want to create a link in /stuff /Index. Html to /things/index. Html, an absolute link is probably called for. That way., if you more/stuff to/more/stuff, your link will still work.
The rule of thumb I generally use is that if pages are part of the same collection, I use relative links, and if they’re part of different collections, I use absolute links.
No comments:
Post a Comment