Have you ever noticed when creating a new WordPress page that linking to library images automatically generates absolute URLs? The CMS’ default setting is to use absolute URLs whenever possible. Even though this can make moving a WordPress site from one server to the next a nightmare, there are very good reasons WordPress developers have chosen this route. Those reasons are explained below.
Before getting to those reasons, it should first be stated that WordPress developers are not intentionally trying to make life miserable for website developers. They have not chosen the absolute URL model because they enjoy making web developers work harder. The absolute URL model is used because it is, in the long run, better for both SEO and website performance.
Absolute vs Relative URLs
For the purposes of clarification, an absolute URL is one that includes a design element’s full structural path on the server. Let’s say you insert a graphic named ‘Image.png’ into a new WordPress post. Choosing that image after uploading it to your media library would produce an absolute URL that looks something like the following:
The absolute path of the image includes both your domain name and the appropriate protocol. A relative URL does not. It redirects to the element in question by playing off the base URL. Below is an example of a relative URL for the same file:
There are different ways to create relative URLs in relation to its base URL. On the other hand, there is only one way to construct absolute URLs. This difference is key to understanding why WordPress defaults to the absolute URL model.
Problems of Relative URLs
With a basic understanding of the difference between absolute and relative URLs, we can begin to grasp why relative URLs can cause problems. A good place to start is something known as the ‘spider trap’.
A spider in the SEO world is nothing more than a piece of software used by search engines to scan and analyze web pages. A spider trap occurs when the software confuses one or more relative URLs and interprets them as redirecting to the same element when the web designer intended them to redirect to different elements. A spider caught in this trap does not know how to interpret the confusing relative URLs.
Another problem associated with relative URLs is duplicate content. For example, let us say a web developer uses the same relative URL structure in his testing environment that also applies to websites he has taken live. Search engine spiders may recognize separate content as being duplicate due to the relative URLs. The duplicate content obviously would not hurt the test environment, but it could do severe damage to the search engine rankings of live sites.
The long and short of absolute URLs is that they protect website performance by reducing errors that could cause search engines to do bad things. WordPress developers got it right, even though absolute URLs can mean extra work for website developers.