Home Contact Scroll Top

What is a Relative Path

What is a relative path? Not to be confused with absolute path, a relative path is a partial path to a file or directory. This is often referred to as a partial path, non-absolute path, or relative pathname.

Relative paths define the location of a file relative to your working directory, or the directory you are currently located in.

These will only contain the name of the specific file or page, which is relative to your current path or directory. It’s complete location is determined by it’s relation to the directory your currently working in.

Relative paths are used to append to absolute paths or to implicitly reference the current working directory.

For example, take the two following links, which are absolute paths.

Absolute Path Examples:

  • https://www.example.com/category/a/page.html
  • https://www.example.com/category/b/page.html

If we wanted to link the first link with the second using a relative path, we could use:

Relative Path Example:

../b/page.html

This is because both directories “a” and “b” are both in the same directory. The “../” portion of the relative path means to go back one directory.

Additional Reading: