Confused by the blog post title? That’s the problem with absolute URLs and relative URLs, and today we’ll look briefly at what the difference is, why you might opt for each type, and what our final opinion is from an SEO perspective.
An absolute URL is a reference (or hyperlink) to a resource in your website directory that could be copied and pasted into the browser address bar and still work. So for example if you had an image called ‘button.gif’ in your ‘/style/images’ folder then in your HTML code you would reference the image by using the absolute URL:
However, a relative URL indicates where the file is in relation to the current document. So we might use the following URL:
Clearly the second URL wouldn’t work if pasted directly into the browser address bar as it is, but it is much shorter. So what are the merits of each, and what would we recommend?
Sometimes relative URLs can confuse search engine spiders, and this can result in incomplete indexing, and so from the point of view of full search engine optimisation it is often recommended to use absolute references. It also means that if you move pages about, copy a site’s content to another domain or create/move directories within a site your references will all still work.
However, relative URLs are much shorter, and reduce the page size, making the site load quicker. As anyone knows, page loading times are now very much key to how high your site ranks in the search results.
So what do we recommend? Basically we would suggest using the absolute references wherever possible, but if your page includes a large number of file references, consider using relative references in order to reduce the file size of the page. In the example URLs above the relative link saved us 27 characters. A web page with 75 file references or internal links could therefore be optimised using relative URLs to save 2,000 bytes, or 0.002 of a megabyte. That may not sound like much, but in conjunction with other speed optimisation methods it could really make a difference.
What’s your preference? Let us know by leaving a comment below.