问题
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?
回答1:
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>
回答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>
来源:https://stackoverflow.com/questions/20599870/how-do-i-link-back-out-of-a-folder-using-the-a-href-tag