What is: Absolute Path

The complete path to a directory or file. It contains the domain name and all other subdirectories that contain the file or directory. Here is an absolute path example in an image tag:

<img src="//www.yoursite.com/images/lasagne.jpg" />

It’s recommended to use // instead of http:// for possible future migrations to https://.

There are also relative paths, which define the location of a file relative to your current working directory. For example:

<img src="images/lasagne.jpg" />

Absolute paths are easier to use and understand. However, if you’re defining paths to website assets which are located on the same server, you should use relative paths. If you were to use absolute paths, you would always have to modify your code before uploading it in order to get it to work. E.g. from localhost to yoursite.com. This would also be the case if you ever had to change your domain name.

Recent articles

loading
×