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:
With a relative path, you skip the protocol and server/domain name and go directly to the page name, like so:
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.