SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Evangelist dhtmlhelp's Avatar
    Join Date
    May 2003
    Posts
    575
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Absolute or relative links

    Hi,

    I have an issue regarding urls. I remember reading (somewhere) that absolute urls are better for usability, unfortunately I cannot remember the reasoning behind this. On the other hand, having relative urls should be more efficient for the server, as using http:// would require one extra request to the server to find out where the file/img is in the file structure, while relative urls indicate that automatically as they are already part of the file structure.

    By visiting a few major sites I have however noticed that they all use absolute urls. My question is, does anybody know which is best, and why?

    DH

  2. #2
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You don't need the http:// part to make an absolute URL, this works too:

    Code:
    <a href="/articles/123.htm"
    I have never heard of a usability issue either way, the browser should phrase the URLs.

    As for you, it does make local development easier if you use relative ones, and it is good to have absolute ones in your 404 pages.

    Douglas
    Hello World

  3. #3
    SitePoint Wizard
    Join Date
    Nov 2000
    Location
    Chico, Ca
    Posts
    1,125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I always use relative links .. the one time I used absolute links I had to go back through and change all the links.. never again.
    "Happiness doesn't find you, you find happiness" -- Unknown
    www.chuckknows.com

  4. #4
    American't awestmoreland's Avatar
    Join Date
    Sep 2002
    Location
    Grand Rapids, MI
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I agree that relative links are best IMO.
    Saves a lot of work if you should change your domain.

    I'm trying to think of a case for using absolute paths, but I can't.
    From the English nation to a US location.

  5. #5
    SitePoint Evangelist dhtmlhelp's Avatar
    Join Date
    May 2003
    Posts
    575
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I agree relative urls are easier for development, however I was referring to usability and speed o the two formats, does anyone have any feedback on this?

    DH

  6. #6
    Ensure you finish what you sta bronze trophy John Colby's Avatar
    Join Date
    Aug 2003
    Location
    University of Central England, U.K.
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is a server issue. Without conducting the experiments I would say that it doesn't matter from the speed point of view as the server will have to resolve whatever links you put into your document. In my thoughts it could matter if you're moving through several levels of directory, for example ../../../../../../../../index.html compared with /index.html (8 directory resolutions instead of a lookup and then one) but this would have to be tested under operational conditions. If you resolve to http://www.yourname.com/index.html then there's extra steps involved with resolving the DNS as well, but that's a different issue.

    But in common with most respondents I use relative links as then I can develop and publish in the same format. And yes, I realise you're referring to usability, but this is the first I've heard of this being a problem.
    John
    No electrons were harmed during the creation, transmission
    or reading of this posting. However, many were excited and
    some may have enjoyed the experience.

  7. #7
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by John Colby
    if you're moving through several levels of directory, for example ../../../../../../../../index.html compared with /index.html (8 directory resolutions instead of a lookup and then one)
    But I thought this was all worked out on the client side: the server doesn't *know* what that would be relative to.

    How about <base> tags? The server wouldn't know about them either.

    In that case, it would make no difference: the server (remember http is stateless) would still get the same, full URL.

    Douglas
    Hello World

  8. #8
    Ensure you finish what you sta bronze trophy John Colby's Avatar
    Join Date
    Aug 2003
    Location
    University of Central England, U.K.
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DougBTX
    But I thought this was all worked out on the client side: the server doesn't *know* what that would be relative to.
    You're right, of course. Serves me right for taking a break from writing a course about server side scripting and happening on here

    Quote Originally Posted by DougBTX
    How about <base> tags? The server wouldn't know about them either.
    Douglas
    <base> is not a tag in XHTML 2.0 - so this problem will be amplified as we progress to this standard.
    John
    No electrons were harmed during the creation, transmission
    or reading of this posting. However, many were excited and
    some may have enjoyed the experience.

  9. #9
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by John Colby
    <base> is not a tag in XHTML 2.0 - so this problem will be amplified as we progress to this standard.
    Didn't know that, but it is a long way off and I'm sure someone will come up with an XWhatever solution to rerelate the links somehow

    Douglas
    Hello World

  10. #10
    gingham dress, army boots... silver trophy redux's Avatar
    Join Date
    Apr 2002
    Location
    Salford / Manchester / UK
    Posts
    4,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    slightly OT: in my 8 years of web development, i have never needed to use the <base> tag...
    i'd go for relative anyway. if there is any kind of client-side "processing" going on as opposed to absolute urls, i would posit that it's so infinitesimally short that it's negligible...
    re·dux (adj.): brought back; returned. used postpositively
    [latin : re-, re- + dux, leader; see duke.]
    WaSP Accessibility Task Force Member
    splintered.co.uk | photographia.co.uk | redux.deviantart.com

  11. #11
    Forensic SEO Consultant Webnauts's Avatar
    Join Date
    Jun 2003
    Location
    European Union
    Posts
    1,488
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here are some interesting links to URLs usability:

    Making URLs Predictable: http://www.bohmann.dk/articles/making_urls_predictable.html
    User-centered URL Design: http://www.tuitionfree.com/node/view/11


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •