Using (hyper) links on web pages
Please do consider to check your web pages from time to time. You can use validation services on the Internet or other tools as you feel fit. Anything that improves the quality of web pages is worth considering. Your mileage with specific tools and/or specific web pages however may and will vary ... keep looking for something that really suits your needs ;-)
To make it easy to manipulate and maintain your web pages, it might be wise to observe the following guide lines when using (hyper) links to web pages on our web server:
-
Use relative links
(i.e. <a href="blabla.html">,
<a href="somebla/otherbla.html"> or
<a href="../blabla.html">), because in this way the
access method you used to get the page containing the link,
will also be used to access the link you requested; what
worked for the page, will (most likely) also work for the link
;-) In this way, you can use the same web page with the same
html code for access via a file://, ftp:// and http:// link! No
matter how you got to the page, you can also get to the links
on the page (this does not apply of course to server
generated pages like php, shtml, Java Servlets, ... since you
really need a web server to generate them properly ;-)
Moreover, when moving your web pages to another directory or another server, you do not need to change any of the links linking one page to another. -
Absolute links
(i.e. <a href="/jaba/daba/blabla.html">) make it
difficult to relocate the web pages and thus should be
avoided. Only use absolute links if you are sure you need to:
if you want to link to web pages that are not related to
and/or in the same directory structure as the page the link is
on (as is certainly the case when using a cgi-bin).
You need to change these links of course when the pages you link to, are moved. But that's a problem for every link ;-)
You need to change these links also when the pages the links are in, are moved to another server than the pages that are linked to. Mostly however, both (sets of) pages will be moved together and thus you do not need to change them.
If the pages you link to are in the same directory structure as the pages the link is on, you should consider a relative link. Using an absolute link still allows for different protocols to access the pages with, but because the path with which to access the pages might be different for each protocol, you are not guaranteed the pages linked to are actually reachable in the specified way (the root for HTTP might be different than the root for FTP and/or the root for NFS). That's why relative links are a better choice, you avoid having to go via that (protocol dependent) root. -
Never use an absolute link to the
same web service as your pages are on
(i.e. for pages that are served by www.cs.kuleuven.be, never use
links of the form <a href="http://www.cs.kuleuven.be/...">).
If you
consider using such a link, consider it not just twice, but
think it over at least 3 or more times!
Such absolute links make it even difficult to just relocate the web pages to a different server, even if the internal directory structure is preserved.
Moreover, you force the client browser to use the http: protocol ... maybe the client is executed in a context where that protocol is unavailable ?
We have not yet found a valid example where you must use such an absolute link to our own web server.
In most cases where you want to use such a link, simply drop the http://www.cs.kuleuven.be part in the URL and you already have something better (in this way your html code does not specify which protocol and which server to use to get to the page). You should still, however, consider to use a relative link, especially if the page you are linking to is closely related to and in the same directory structure as the page the link is on.
When referring to a lot of pages in the same directory structure that is not closely related to the one the web page itself is in, you might consider using a <base href> tag. But in this way you create a dependency on the actual machine these pages are served by because a base href tag must include the http://machine part in the URL. Moving the entire directory structure to a different machine (as when upgrading to a new web server ;-) might force you to having to edit and change each page containing such a base href tag.
It might be better to work with a symbolic link : put a symbolic
link to the (top of the) directory containing the pages you want
to link to. This symbolic link points to the same directory the
base href would point to and thus it is exactly the same to
maintain, except that you no longer have a dependency on the
actual machine the pages are served by.
You can then link to the files via this symbolic link, that is
in the same directory as the web page itself. Thus the hyper
links are short and simple. The pages you link to, must of
course be served by the same web server as the page the links
are in.

