Forum Moderators: Robert Charlton & goodroi

Message Too Old, No Replies

Absolute vs. Relative linking

which one to use?

         

v_michiel

2:11 pm on Aug 14, 2005 (gmt 0)

10+ Year Member



Hello there,

Here's a quote of what GoogleGuy said in the past:

My rule of thumb is to pick a root page and be as consistent as possible. I lean toward choosing [yourdomain.com...] but that's just me; [yourdomain.com...] would work as well. Then I recommend that you make things as simple as possible for spiders. I recommend absolute links instead of relative links, because there's less chance for a spider (not just Google, but any spider) to get confused. In the same fashion, I would try to be consistent on your internal linking. Once you've picked a root page and decided on www vs. non-www, make sure that all your links follow the same convention and point to the root page that you picked. Also, I would use a 301 redirect or rewrite so that your root page doesn't appear twice. For example, if you select [yourdomain.com...] as your root page, then if a spider tries to fetch [yourdomain.com...] (without the www), your web server should do a permanent (301) redirect to your root page at [yourdomain.com...]

Now here's my probably rather n00bish question: "what are absolute links and what are relative links?" Is an absolute link for instance "http://www.yourdomain.com/subpage1.html" and a relative link "subpage1.html"?

And so GoogleGuy here does say that also for internal linking the absolute links are preferred? Cause I always thought that was considered spam...

goodroi

7:58 pm on Aug 15, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Yes absolute links contain the full url and will work from any page or any site and relative links contain partial url and will not work the same everywhere. Another reason to use absolute links is to get some benefit when people steal your content. Alot of people don't bother to strip out the links when taking content. As for interlinking, it is encouraged as long as it is done for user benefit.

Small Website Guy

3:13 am on Aug 16, 2005 (gmt 0)

10+ Year Member



A large percentage of links are relative links, so any search engine that couldn't figure them out would suck as a search engine.

europeforvisitors

6:03 am on Aug 16, 2005 (gmt 0)



GoogleGuy also said that, if you're using relative links and you're getting crawled, you shouldn't feel compelled to change them. (I'm paraphrasing, but that was the gist of his message.)

lammert

10:00 am on Aug 16, 2005 (gmt 0)

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



Another reason to use absolute links is to get some benefit when people steal your content.

Absolute links are very helpful with DMCA complaints. Many content thiefs don't change absolute links to images for example. I had some very succesful DMCA complaints by just stating "you can see on the copied page at www.thief.com that the images are still loading from www.owner.com". Complete sites were blocked by the hosting company within 24 hours.

Also if someone is 302 hijacking your page, all links from the hijacked page are still pointing to your site, not the hijacker. So you will still receive some traffic via the hijacked page. There have also been posts on this board that the chance of being hijacked is smaller when you use absolute links throughout your site, because the Google algorithm can easier determine which URL is the original, and which one the copy.

If you don't want to change all the internal links, you could use the <base href="www.yourdomain.com/file.html"> in the head section of each page. This tells the browsers and bots that all relative links on the page should be calculated as if the current HTML file is www.yourdomain.com/file.html. This has some of the advantages mentioned above and is in general not a large amount of work, especially if you use common headers in PHP, SSI, ASP or another server side scripting language.

rituel

10:11 am on Aug 16, 2005 (gmt 0)

10+ Year Member



Excuse me for my bad english :

The way you build your links has no impact on SEO ... But Absolute linking avoid errors and save search engines server's resources.

Rituel

Brett_Tabke

1:19 pm on Aug 17, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Just to refresh the memory here for the new folks:

Absolute Link:
<a href="http://www.webmasterworld.com/forum30/">Google News</a>

Relative Link:
<a href="/forum30/">Google News</a>

> The way you build your links has no impact on SEO,

It has in the past because of spiderability issues and it may in the future. I have a popular browser here on my phone that has difficulty with relative links in it's own cached pages. How many bots is that true for today? Even Google itself had difficulty with relative links in its own cached pages in 2000-2001.

> I recommend absolute links instead of relative links

Ditto where possible. However, the bandwidth savings from relative links on high traffic sites is significant.

DaveAtIFG

4:03 pm on Aug 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The way you build your links has no impact on SEO
Using keyword-stuffed-domain-name.com effects keyword density.

g1smd

8:33 pm on Aug 17, 2005 (gmt 0)

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



I avoid links like ../../../folder/

I always count from the root /folder/subfolder/page.html

If you have a 301 redirect set up from non-www to www then you can still use relative links, with a low risk. Without a redirect you will have duplicate content issues.

When you link to an index page do not include the index file filename in the link. End the link with the trailing "/" on the URL. Link to / or /folder/ or http://www.domain.com/ or http://www.domain.com/folder/ only.

Always include the trailing / on the end of the URL when you link to a folder.

2by4

2:00 am on Aug 18, 2005 (gmt 0)

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



If you run a development version of your site locally using relative links is the way to go, you can use scripting to replace them with absolute ones when the pages run on the web server, but what a pain...

But avoid using ../folder/file.html type paths, those are a real pain to maintain longterm, always start from the root, /folder/file.html, as g1smd says.

"Even Google itself had difficulty with relative links in its own cached pages in 2000-2001."

that was a long time ago. What cellphone browser are you having trouble with?

victor

7:23 am on Aug 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you run a development version of your site locally using relative links is the way to go, you can use scripting to replace them with absolute ones when the pages run on the web server, but what a pain...

One person's pain is an essential part of another's an quality control steps.

I use an uploader to make pages live. As it uploads them it expands all relative links to absolute ones. Also it:

  • only uploads pages that have changed -- so it's fast
  • uploads them in a sensible order (so lower "internal" upload before higher up ones -- so there should never be a link to a new, not yet uploaded page, even for a moment
  • run a spell check -- so I never knowingly have bad selping on the site
  • run a link checker -- ditto broken links
  • check the pages into a source control database -- so I can retrieve old versions if needed

    I end up with a site that is 302-hijack resistant, and has had a lot of quality checks run pretty much for free. No pain and a lot of gain.

  • philipkd

    9:46 am on Aug 18, 2005 (gmt 0)

    10+ Year Member



    Use relative links. You will move your site to a different domain name in the future. Or once your site is finished, you will probably give up the domain or the hosting related to the domain, and so you'll want to view your site from a CD-Rom or locally on your harddrive for archiving purposes.

    lammert

    7:19 am on Aug 19, 2005 (gmt 0)

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



    You will move your site to a different domain name in the future. Or once your site is finished, you will probably give up the domain or the hosting related to the domain

    I guess this is only true for a minority of the webmasters. Most of us want a long and successful existense on the web on a branded domainname.

    Also putting a website on a CD-ROM or harddisk to work is getting more and more difficult today as the percentage of server side script driven sites (PHP, ASP, etc) is ever increasing. Only plain HTML type websites can be transferred to a local disk without any rewriting or installation issues, but as this eliminates the visibility of the site, it is hardly what most webmasters are aiming.

    mrMister

    4:32 pm on Aug 19, 2005 (gmt 0)

    g1smd

    6:10 pm on Aug 19, 2005 (gmt 0)

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



    Much has changed since November 2002.

    2by4

    12:01 am on Aug 22, 2005 (gmt 0)

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



    "Only plain HTML type websites can be transferred to a local disk without any rewriting or installation issues"

    That's not true, where did you get this idea from? I only have to add one thing to run my sites locally, some httpd.conf stuff, they are all developed locally, then installed on the server.

    Obviously if the site is created from a database, like some forums, cms systems etc, you'd have to load the database contents too to duplicate the sites, but that's not very hard.

    lammert

    6:28 am on Aug 22, 2005 (gmt 0)

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



    That's not true, where did you get this idea from?

    philipkd was mentioning viewing a site from a local CD-ROM, or putting it on a local disk for archiving purposes. If you want to do this with only a browser, you need the website to be in plain HTML. Of course you can install a database server and httpd server, but IMHO this was not wat he was talking about.

    If there is any sort of server side processing in the source files (SSI, ASP, PHP, database access or whatever) you need to install server software to process the source.

    with "(...) some httpd.conf stuff" you are already assuming that there is a local web server running.

    Obviously if the site is created from a database, like some forums, cms systems etc, you'd have to load the database contents too to duplicate the sites, but that's not very hard.

    Load the database assumes again that the necessary software is already in place, which I would call "installation issues". Also, how would you run a website from a database if it is viewed from a read-only CD-ROM? MOst CMS software needs write access to the database just to start up.

    Small Website Guy

    1:34 pm on Aug 22, 2005 (gmt 0)

    10+ Year Member



    I develop websites using ASP.NET and I need to run them locally on my computer to test/debug/develop them. Using absolute links would kill your ability to run the site locally.

    On the other hand, if having absolute links is really that importnat, ASP.NET provides an easy way to do that if you use the "server controls" and use the tilde character (~) to represent your home path.

    Nevertheless, I really don't think that any modern search engine would have any problem with relative links

    luckychucky

    1:46 pm on Aug 22, 2005 (gmt 0)

    10+ Year Member



    any modern search engine

    tee hee, that's cute:

    Modern

    mrMister

    1:51 pm on Aug 22, 2005 (gmt 0)

    WebmasterWorld Senior Member 10+ Year Member



    Much has changed since November 2002.

    I can assure you that the definition of a relative link has not changed since November 2002.