10

Alright so I have a page in a folder, the page is called jobs.html and the folder is simply called "jobs". Its a sub folder of my mine "website" folder. In the main directory of the "main" folder is my "home.html" file. When I try to do

<a href="home.html">bla</a>

It malfunctions as it is looking for the home file in the jobs folder, which does not exist.

So I ask, how can I reference out of a folder to call a file from the root folder?

Giacomo1968
  • 25,759
  • 11
  • 71
  • 103

2 Answers2

28

Try setting your link to be your site root as so; note the / in front of home.html:

<a href="/home.html">bla</a>

Or if you know the path is definitely one directory down then just explicitly tell it to go down 1 directory; note the ../ in front of the home.html.

<a href="../home.html">bla</a>
Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
  • For some reason putting the /home rather than ../home lead straight to my root directory on C:, which is strange. The double dots ended up working though. –  Dec 15 '13 at 21:25
  • 3
    Well, the `/home.html` would work if you are loading the page through a web server. If it is going to your root directory on your `C:` drive, then you are loading the page as straight HTML in your browser. – Giacomo1968 Dec 15 '13 at 21:32
2

You can move up a directory by using ../ before your html document. So if home.html is up one directory, you could do:

<a href="../home.html">bla</a>
Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
CDub
  • 13,146
  • 4
  • 51
  • 68