Absolute and Relative Server Paths

Every site has links that point to other pages, documents, images, and even other sites. While most people understand the concept of a link, they get confused about what type of link to use under which circumstance. Linking is done by using a server path. Think of the path like a map, a set of directions that tells the computer where to find that information. How the computer determines the location of the destination file is determined by the type of path.

Creating Relative Paths

Relative paths, also called relative links, are shorter and tell the computer to begin where it is. The computer will begin looking in the folder the parent file (thats the page it is on) is in. In the example below, the image.png file is expected to be in the same folder as the file that is calling it.

<img src="image.png">

The next example also begins with the folder of the file that is calling the image, but it is looking for a folder named images within its folder and then the image.png file.

<img src="images/image.png">

You can even set the relative path to go back up to a folder above the calling file if needed. In the example below, the images folder is above the folder of the calling file, so it uses a prefix of ../ to indicate it needs to go back up one folder and then begin looking for the images folder.

<img src="../images/image.png">

Relative linking is very useful when used within the site itself. Most Content Management Systems (CMSes) are designed to use relative links. This is so if the site is ever renamed, all the internal links for pages and images will not break.

It is extremely important to use relative paths if you plan on securing all or part of your site with SSL. The site will need to deal with both the regular (http://) as well as the secure (https://) protocols. Absolute paths will not allow this to happen and it can break the SSL security indicator on the site.

Creating Absolute Paths

Absolute linking or paths are very straightforward. All external linking (links to other sites) need to use absolute paths. This type of linking assumes nothing and gives the very specific location of the file as if it was always external. For example, if your site is example.com and you want to link to the image.png file in the images folder, then it will appear as in the example below.

<img src="http://example.com/images/image.png">

Note that the entire domain address is included, even the procotol portion (http://). If you ever need to connect to a secure protocol (https://), you would need to make sure that is part of the path as well.

As you can see, using the proper linking type is important. Using the wrong type of linking can have adverse effects on your site when you change something up such as using SSL or renaming the site. Knowing the difference can save you a lot of troubleshooting or downtime with your site.

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Did you find this article helpful?

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!

Help Center Search

Current Customers

Email: support@WebHostingHub.com Ticket: Submit a Support Ticket
Call: 877-595-4HUB (4482)
757-416-6627 (Intl.)
Chat: Click To Chat Now

Ask the Community

Get help with your questions from our community of like-minded hosting users and Web Hosting Hub Staff.

Not a Customer?

Get web hosting from a company that is here to help.