Have you ever heard of absolute versus relative URLs? Did you wonder what the difference was and why it mattered? Here’s a handy tutorial to help you out.
When talking with a developer, especially if you are talking about a WordPress website, you might hear them say something about an absolute or relative URL. It’s not just another website development term you can gloss over – it’s actually pretty important.
An absolute URL is a ‘full’ URL or one that contains the entire address of the page. These types of URLs are often found when a website is linking out to another website that is not using the same server as your website. When your browser sees this type of URL, they start at the beginning and navigate to the domain – in this case yourwebsite.com - and then to the folder called ‘images’ and then it looks for the image called ‘logo.png’
A relative URL on the other hand assumes that the first part of the URL is the same as your current location so you only put the path of the URL relative to where you are in the folder structure. This won’t work for websites on different servers (ie if you are linking to a third party website) but can make it easier to link to different pages or images on the same website. There are a few different ways you can link to a file using this method:
An absolute URL makes it harder to switch domains however they always work and it’s harder to make a mistake.
Relative URLs can be much shorter and quicker to write. It’s also helpful when you have to change URLs. For example, you might develop the website using the URL http://YourWebsiteDemo.com and then change it to http://YourWebsite.com once development is completed. If you are using relative URLs, you don’t have to change anything because the browser fills in the domain for you. If you were using Absolute URLs, you would have to manually go in and change every link to the new domain.
There is also software that requires a specific URL structure like WordPress. WordPress requires that all URLs are Absolute for everything to link correctly. That means when we are moving your website from a dev environment to the live website, we need to go in and update the links so it will show correctly. This also means it’s important to limit changing URLs as much as possible. We try to get final approval on the URL we are using before we launch your website so we don’t have to make additional changes and risk missing an old URL.