Links not going back a directory?
You need to give a relative file path of <a href="../index.html">Home</a>
Alternately you can specify a link from the root of your site with<a href="/pages/en/index.html">Home</a>
..
and .
have special meanings in file paths, ..
means up one directory and .
means current directory.
so <a href="index.html">Home</a>
is the same as <a href="./index.html">Home</a>
How do I link back out of a folder using the a-href tag?
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>
Relative Links to parent folder are not working
So, I have found a solution or rather I followed some troubleshooting steps, that did it.
- cleared browser cache again.
- I deleted the html file and then saved it again. I am using Sublime, so the
content remained, even after the file had become deleted. - I did refresh the site
And out of the sudden all was working. Strange still, never had that happen before. Either way, it is now working.
href=../ links to root instead of parent directory
Here is a couple of things I would try to do:
(1) Check web server redirection settings
(2) Does the web server require file extension (ex. .html .htm) to properly load the page? You can probably try ../index.html if the root file of the parent directory is named index.html.
Html directory link not working if the directory is not from the beginning
You have to look where is the .html file located on the hierarchy. If you are in dmca.html and you have a href on that page to second.html, you will need to jump backwards to the pages directory, and then go to the file: ../second.html
Now, if you are in index.html, and you have a href linking to dmca.html, you will need to hop back one level, enter pages directory, and choose the .html file. So it would be like this: ../pages/dmca.html
-public_html
|
|--index.html
|--pages
|--dmca.html
|--second.html
If I have not explained myself correctly, or I've understood the question wrong, please tell me.
What is happening, if I understand the problem properly, is that you are in index.html, and you want to href dmca.html, but the route you use pages/dmca.html
, doesn't work, but if you use ../../public_html/pages/dmca.html
, then, it does work. And I guess you are asking why is this happening.
Well, what happens when you use pages/dmca.html
is that you are saying: search for a subdirectory called 'pages' and go to the file inside it called dmca.html. This would be correct if you had this hierarchy:
-public_html
|
|--index.html
|--pages
|--dmca.html
|--second.html
But index.html is a file, so it can't contain subdirectories. That's why you have to go one level up the hierarchy, and then, once you are in public_html/ you can choose to load index.html or go to the subdirectory public_html/pages and choose a file from it.
How to go up a level in the src path of a URL in HTML?
Use ..
to indicate the parent directory:
background-image: url('../images/bg.png');
Related Topics
How to Add HTML Code to Jsf Facesmessage
Where Is The Default Size of a Div Element Defined or Calculated
Angular4 - Scrolling to Anchor
How to Convert an HTML Table to Csv
What Do Square Brackets in Class Names Mean
Can HTML5 Websockets Connect 2 Clients (Browsers) Directly Without Using a Server? (P2P)
CSS Selector for No-Children-But-Not-Empty
A True Sticky Footer with a Fixed Header
Gmail Displaying Gaps Between Images
How to Put Img Inline with Text
How to Use Nth-Child for Styling with a Table with Rowspan
Do Custom CSS Properties Use One Leading Dash or Two
CSS Calc Viewport Units Workaround
Schema.Org/Microdata Markup for List of Recent Posts Without Providing "Author"/"Publisher"
Why Use Definition Lists (Dl,Dd,Dt) Tags for HTML Forms Instead of Tables