How to do best the linking between files on LinuxFocus
- Linking relative
- Linking absolute
- Checking links
This guide describes how to use the html href= or the src= in
the best way on LinuxFocus.
The general rule is that relative links should be used.
Examples of relative links are:
The advantages of these relative links are that:
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.
- They are easy and fast to check with automatic tools
- They are location independent. I.e you can move things
around without changing all links.
- They will work on all mirror sites
- You can build archives from it that you can read off line
E.g consider the links http://some.where/cgi-bin/prg
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: http://cgi.linuxfocus.org/cgi-bin/......
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:
What is the difference?
- 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.
- 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
- This type of linking refers always to News/index.html. It is
probably the best method
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.
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.
tr_llnk -A the_html_file.html
when you recieve an article and check that the linking is correct.
Tue Apr 8 21:07:15 CEST 2003
by guido socher