link paths in big sites: relative or absolute? discuss...

liunx

Guest
Hi there,<br />
<br />
I have a topic for discussion that I have been thinking about ever since I became a web developer.<br />
<br />
Link pathways (for images, scripts etc).<br />
<br />
Should they be relative, or absolute?<br />
<br />
I was always taught that RELATIVE is the way to go, but when you have a BIG site (>100 pages), it becomes harder and harder to reference pathways relatively (you end up with lots of "../../../../images/image.gif"). Also, say you have a script that you want to reference (call it "script.js") that contains pathways to images (say, for rollovers) - these pathways will not work with relative links for .html files way down in the hierachy, because the "script.js" that you call will have the wrong pathways for that file.<br />
<br />
I am not so much interested in a solution as such, just what other people think.<br />
<br />
Someone once suggested for me to use variables for pathways - but I don't know how this would work - if someone could give me an example I would appreciate it.<br />
<br />
Looking forward to getting some interesting answers :).<br />
<br />
Cheers,<br />
<br />
Tatlar<!--content-->You should have created a poll, but anyway..<br />
<br />
I prefer RELATIVE paths so that when I need to switch hosts, I can do that with ease. Scripts sometimes become a problem.<br />
<br />
Also, anyone who gets hosted with a free host SHOULD you relative paths so that when the host shuts down and they move to a new host, they won't have a big problem. ;)<!--content-->how do you create a poll?<!--content-->Originally posted by tatlar <br />
how do you create a poll? 1.Click the "New thread" button<br />
2. Type the subject, Message...<br />
3. Just above "Submit new thread" button, checkmark the box where it says "Yes! post a poll"<br />
4. Pick how many polling options you want<br />
5. you are taken to a page where you can create you poll options...<br />
6. submit.<!--content-->actually absolute paths are generally used in the serverside langauge. I hardly ever see anybody use absolute paths for images. most general webmasters use relative and leave absolute to the back end (serverside).<br />
<br />
actually on regular html you should use the relative or the url and leave the absolute paths to the serverside languages.<!--content-->I have over 200 pages and I prefer using relative paths. Most of my stuff is in a general layout though... pages in one directory, images in one directory, examples in one directory, and so forth... so if I need to access a specific file, I know where to look already.<br />
<br />
There are a few paths that are absolute, just because, but I would say about 98% are relative.<br />
<br />
I think I mainly went this route too because most of my coding is done offline and it helps when it comes to previewing offline. I can essentially have a mirror of my site available to me without being online.<!--content-->so what about client-side scripting references - absolute or relative?<br />
<br />
define an array? (example please!)<br />
<br />
tatlar<!--content-->I use absolute. There is good reason for me to use it. Lets say I call an image from my root to my image dir.... something like /images/pic.jpg think of how many times that would change if I wrote the page differently, or implimented a new directory structure and placed the page in a new directory 2 levels down. None. Not once. <br />
<br />
Also, I use includes on almost every page... and quite often use the same include in ALL directories... and call scripts and pictures in those includes. I can't use ../../../ because it would only work in one instance. <br />
<br />
Using absolute linking takes no extra time, and is a better solution for the long run, no matter if your using client/ server or both.<!--content-->
 
Back
Top