How to do best the linking between files on LinuxFocus


  1. Linking relative
  2. Linking absolute
  3. Checking links


This guide describes how to use the html href= or the src= in the best way on LinuxFocus.


Linking relative

The general rule is that relative links should be used. Examples of relative links are:
<a href="file.html">......</a>
<a href="../somefile.html">...</a>
<img src="../../common/images/pict.gif">
The advantages of these relative links are that:

  1. They are easy and fast to check with automatic tools
  2. They are location independent. I.e you can move things around without changing all links.
  3. They will work on all mirror sites
  4. You can build archives from it that you can read off line
Relative links can however also cause trouble is a few rare cases. It is possible to group on the web-server directories logically together that are not located in the same place in reality.
E.g consider the links http://some.where/cgi-bin/prg and http://some.where/dir/index.html
Very often the cgi-bin directory is logically a subdirectory of the root directory on the server. You can therefore get from the index.html file in to above example to the cgi-bin/prg by using "../cgi-bin/prg". Physically the cgi-bin directory is however in most cases in a totally different place.
The recommendation is to use relative links only when files are physically located in the same place. Therefore use abs. links to cgi:

On LinuxFocus the following directories are e.g in the same place:

Castellano/ Chinese/ ChineseBig5/ ChineseGB/ Deutsch/
English/ Francais/ Italiano/ Korean/ Nederlands/ Portugues/
Russian/ Turkce/ WorkSpace/ common/ doc/

A special case of relative linking are links to directories.
E.g consider a subdirectory called News in English/
From English/index.html you can get to English/News/index.html in the following ways:

  1. "href=News"
  2. "href=News/"
  3. "href=News/index.html"

What is the difference?
  1. Never use this type of link. It has the following problems:
    -The web-server needs an extra check to see if this is a file or a directory
    -If you put the page into an archive and just open it with the file: URL then it will fail. I.e this type of link works only if you have a web-server.
  2. You can use this type but be aware that it opens without the web-server (archive opened with file:) the directory and not News/index.html
  3. This type of linking refers always to News/index.html. It is probably the best method

Linking absolute

There is two ways to link absolute:
Never use the first one! It depends on the position of the document root on the specific server. It fails on some mirrors and when you just open an archive of LinuxFocus with the file: method.
When you have to use absolute links then use the second one.  

Checking links

On Guido's homepage you find the HTML::TagReader package. It contains a program called tr_llnk which can be used to list all links in a html page. Just run
tr_llnk -A the_html_file.html
when you recieve an article and check that the linking is correct.
Last updated Tue Apr 8 21:07:15 CEST 2003 by guido socher