January 16th, 2008 - by Golgotha

Absolute vs. Relative Links - Which is Better?

There are two ways to link to a file/page/location in HTML, either by using absolute or relative paths:

An absolute path defines a location by including the protocol, the server/domain, the directory (if needed) and the name of the document itself. Below is an example of an absolute path:

<a href="http://www.search-this.com/page.html">

With a relative path, you skip the protocol and server/domain name and go directly to the page name, like so:

<a href="/page.html">

So which is better?

Well you’ll get different responses depending on who you ask. Many people will tell you that relative paths are better but I’m not one of them! I always recommend absolute paths and here’s why:

At one point GoogleGuy, an employee of Google, who helps fight crime — or at least helps webmasters — said, and I quote, “absolute links have less potential for getting messed up [when Google indexes your page]. Even though it shouldn’t make a difference, I recommend absolute links.”

OK, sure, maybe just because GoogleGuy said so is not a good enough reason. I agree. So here is — we live in a time where people scrape your content and place it on their own site. If you’re going to get scraped you may as well get a link back to your site, right? That’s only going to happen with an absolute path!

And it’s not just scrapers. There are other legitimate ways to have your content show up on other sites; like RSS and web-services. I think in todays web, it’s no longer just personal preference; absolute paths are the way to go.

11 Responses to “2 Minute SEO Tip - Absolute vs. Relative Links”

1 Jack @ The Tech Teapot

I think you’re right. We are using relative at the moment and it will be a big job to move over to absolute. I’ve seen instances where Google has got links wrong. Google cache doesn’t seem to work too well either with relative links.

2 Dustin Brewer

I don’t agree with this at all for a lot of reasons. Trying to make your site get in-links from scrapers is a null point and ridiculous.

You want to use relative paths as much as possible, they are not only going to take the file size of your site down but when working from a development point of view it is mandatory to use relative links.

The biggest reasons for this is most developers use a “development subdomain” that you will be working on the project until it goes live. You don’t want to go back and change all of them to the new domain if you are using absolute.

Using relative paths is a just good practice (almost a standard) in web design.

3 Jack @ The Tech Teapot

@Dustin - using a config file is pretty easy to do with the correct domain to use on your live domain and your stage sub-domain.

4 Golgotha

@Dustin - “Trying to make your site get in-links from scrapers is a null point and ridiculous.”

Not when your site is scrapped by a dozen sites like this one is…

“You want to use relative paths as much as possible, they are not only going to take the file size of your site down”

file size, talk about a null point…

And Jack is dead on, you would just use a config file to change from development to production. It’s real simple. It’s what WordPress does, and it’s what you should do too.

So in the end relative pathing gains you nothing, save a few bytes.

5 Adi

Well recently it was revealed that “GoogleGuy” is none other than Matt Cutts. :)
Hence, obviously what he has said, is definitely correct.

6 Ahmet

One more reason to enter absolute path:
You will write more time your domain name (considering it makes certainly part of your SEO strategy), I totally agree with what you said: Absolute path is the way to do it :)

7 URLs and SEO and Internet Marketing

[...] Absolute vs. Relative Links - Which is Better? (Search-This) — “Well you’ll get different responses depending on who you ask. Many people will tell you that relative paths are better but I’m not one of them! I always recommend absolute paths and here’s why…” [...]

8 Web Design Media

There’s no point in saving a few bytes when using relative links…except if each page of your website contains thousands of links. However, as @Dustin says, relative links is a good practice.
We can’t deny the fact that in-links contribute to page ranking.
So, the solution is simple. You just have to use both of them, wherever necessary.

9 Wil

The only pain with absolute links, which I do prefer for too many reasons to list (and only a few for “not”) is when your internal or external engine points you to the “www” path (or not) and when you get your search results you get relative links.

If your absolute links take you from there to a “www” path (or not) and you have login credentials on that folder, you’ll be prompted for login credentials everytime you go from “www” to just “http” and vice versa, so there’s the chance for one addtl. login prompt along an absolute path where htaccess exists in the folder….

10 Chris Shepherd

Absolute links are better in my opinion and you could say yeh but what happens moving from dev to test servers with different base domains… however if you use a content mgt system then this can be managed quite easily.

If the end product in the HTML is an absolute link, then that’s the best for me, even if what’s stored in the CMS is a relative link making it best practice.

11 Link Building Bible

Wow…. I never thought of it with regards to scraping, but this is awesome! I will be writing about this very soon on my blog in my internal link building series.

Share your thoughts...

WordPress Plugins

Blog Categories

Meta

Add this blog to my Technorati Favorites!

Popular Articles

Top 10 Commentators


Subscribe to this feed! Subscribe by Email!

Random Bits Podcast

You need to download the Flash player from Adobe

Blogs Worth Reading