Forum Moderators: open

Message Too Old, No Replies

Links / href (absolute vs. relative)

         

llmm123

9:25 am on Apr 3, 2007 (gmt 0)

10+ Year Member



Hi all,

Just a quick question:

Is it good,bad or indifferent how you structure you links. I.E does it matter whether I do it like this:


<a href="../mypage/testpage.html">My test page</a>

OR like this (the whole path)


<a href="http://www.mywebsite.com/mypage/testpage.html">My test page</a>

Obviously the second example will make things difficult when developing because if I click on the link, locally when testing, it will reference to the web server, but other than that, is it a problem or not?

Thanks,
LL

bill

9:34 am on Apr 3, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This is a continually debated topic. You're talking about the difference between absolute and relative links [google.com].

llmm123

9:55 am on Apr 3, 2007 (gmt 0)

10+ Year Member



Thanks bill, yes, thats it - absolute vs relative. I checked through some of the posts and I think I am going to go for absolute links.

Thanks again.

LL

Fotiman

5:53 pm on Apr 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I generally prefer links that are relative to the root of the application/site I'm working on. For example:

<a href="/mypage/testpage.html">My test page</a>

Absolute links can not easily be tested in a development environment (because the links will all point to "live" pages instead of to your development pages). There is no SEO advantage to absolute links.

piatkow

11:04 am on Apr 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I always understood that relative links gave a performance benefit in the days of 28k modems.

From some comments that I have seen in the Google forums some people think it important to be consistent with one format or the other. I haven't risked a duplicate content penalty on my site to test that!

kaled

11:05 am on Apr 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As I see it, there are only two pros to absolute links,
1) Some people believe it helps prevent page-hijacking (by redirects). I think this is still a problem with Google but I'm not certain.
2) It creates a slight problem for scrapers. If your pages are copied, there is a chance that the copier will fail to change the links, but this could be done by automated tools.

To some extent, it depends on what tools you use. If you use static html, page-relative links are probably best since they will not break even if you move whole directories around.

Kaled.

g1smd

7:42 pm on Apr 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I prefer to start all URLs with a / and therefore count from the root.

The exact domain in use is taken care of with a base tag on each page and a set of 301 redirects in .htaccess take care of all other domain and URL canonicalisation issues.

anax

8:34 pm on Apr 6, 2007 (gmt 0)

10+ Year Member



In the past I have always used relative links in the form href="/mypage.html" but have recently converted everything to absolute (href="http://mysite.com/mypage.html"). Why? Because I noticed that if someone copies your page (either carelessly or maliciously), the absolute links will continue to point a user back to your site, whereas the relative links will just be broken, or may cause the page thief to change all the links to his site. (A determined thief can always do that anyway, but I've found that some people are just lazy and cut and paste the source when copying.)

g1smd

8:36 pm on Apr 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I used to do it like that, but soon realised that the base tag took care of that, whilst still saving bandwidth in not repeating the domain information on every internal link.

[edited by: g1smd at 8:44 pm (utc) on April 6, 2007]

anax

8:38 pm on Apr 6, 2007 (gmt 0)

10+ Year Member



Yes, I've used the BASE element also, but I've found a number of cases where people just cut and paste a chunk of a page, not the entire document. When they do that, relative links get broken.