问题
There are already some posts about this subject, but it couldn't help me. I've made a map structure for HTML and CSS pages, but I can't get them linked to eachother.
My map structure:
PO Webdesign
- Homepage
- HTML Page Homepage
- CSS Page Homepage
- Images Homepage
- Sports
- HTML Page Sports
- CSS Page Sports
- Images Sports
- Food
- HTML Page Food
- CSS Page Food
- Images Food
- Sleep
- HTML Page Sleep
- CSS Page Sleep
- Images Sleep (For example, to get to Images Sleep it's PO Webdesign --> Sleep --> Images Sleep)
In my navbar on my homepage I've tried those links (For the other pages the other subjects of course):
<A Id="Link" Href="../../Food/HTML Page Food.html">Food</A>
<A Id="Link" Href="PO Webdesign/Food/HTML Page Food.html">Food</A>
<A Id="Link" Href="/../Food/HTML Page Food.html">Food</A>
Does anyone knows how I'm supposed to do the relative file paths if I want to link my HTML pages in the navbars on other pages with this map structure?
Thanks in advance, Tess
(Sorry for the bad English, it's not my native language)
回答1:
First, please read this answer (and others, too): https://stackoverflow.com/a/23772318/216846
You can use those relative urls (even if it is not generally a good idea).
If your homepage url is "/Homepage/HTML Page Homepage.html" you should be able to refer to Food through.
<a href="../Food/HTML Page Food.html">Food</a>
Note, that you have to omit the leading "/" from the URL to it be relative to current page. Otherwise it is relative to the root page of your website.
But, still, you should use
<a href="/Food/HTML Page Food.html">Food</a>
来源:https://stackoverflow.com/questions/53277931/question-about-relative-file-paths-in-html