I'm having a serious issue linking from a page in one folder to another page in a different folder.
Here is the relevant structure.
The link is on navbar.php:
Project Folder
-includes/navbar.php
-savings/food.php
Here is the code for the link:
Food
I thought that this syntax would point to the right place. '../' bringing it back one level to the main folder and then '/savings/food.php' pointing to the right folder and page.
I'd be very grateful to anyone that can help me figure this out.
Folder Structure:
Project Folder
-includes/overall/top.php
This is where the navbar is included and top.php is included into the other pages
When you click on your link, where does it take you now?
Related
I am creating a school project website and is organizing my files to different folders. From root folder to css, script, etc... This is the structure I made.
But I couldn't access my index page from subpages. If I am to go from index to about us for example:
<a href="pages/about-us.html">
It would take me to the about page. But going back to index, I tried:
<a href="root/index.html">
and
<a href ="index.html">
But no luck. Surely, it would work if I would copy paste the exact location in my PC. But I will upload this for my professor to see. Also, not to mention the images too that I need to link from a folder up from the subpages. If that make sense.
Bottomline: How do I link files from different folders whether one folder up or one folder down?
Thank you in advance. :)
Using ../ allows you to jump back a directory (folder) and ../../ would jump back two directories. If your at the root directory you can access a file with /index.html. Have a look at the Dealing with files - MDN documentation for more detailed information.
My problem is that I have a bunch of HTML files but in simple I have public_html/pages folder + index.html/under pages folder a dmca.html is located.
So when I want to locate the file using href = "pages/dmca.html" it doesn't work and on another side when I use "../../public_html/pages/dmca.html" from the beginning it works is it normal or something wrong so I can only use the simple way as I have mentioned above(the link)
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.
Right now I'm working on my web page, and... rethinking about it, I have to say that you were right, I mean, what you were doing was supposed to work.
Look at my directories. I have a htdocs folder, inside it I have some .png, index.html, and a folder called "prova", inside the folder "prova" I have index2. You can see that it is the same case as yours. I have an href on index.html that says href="prova/index2.html" and it works for me. Actually what I've said to you on the morning is wrong. I'm sorry :/
Because if I write ../prova/inedx2.html what happens is that the folder "htdocs" is removed from the URL. Remaining as: "PortàtilHP_antic_pare/prova/index2.html" You can see that the folder between "PortàtilHP_antic_pare" and "prova", which should be "htdocs", has disappeared.
So now I'm wondering how my answer has been useful for you. I guess I have understand it wrong, and somehow, my answer has made you change something that somehow has worked.
I know this is a very basic question but I am struggling a low for this problem. This is my project hierarchy and I am having an href on the home button which would direct to the contact-us.html page in my html folder but I am not getting the path which I should write. It always shows error 404.
I have tried
/ZingyBeesTest/html/contact-us.html
/ZingyBeesTest/WEB-INF/html/contact-us.html
/html/contact-us.html
and many more. What should I write? I am facing the same problem with images. That is why I have pasted all the images in the same directory as my index.html.
EDIT :
One of my mistakes was that the web.xml and servlet file must be present in the WEB-INF folder and not in the Web Content folder. But the links still do not work.
I am having a hard time rendering/ successfully hosting images on Github.
My github repository has the following link tree structure: michaelamay/projects/post.html
and there is an image folder with the structure: michaelamay/projects/images/
In my code i add that to the src in 3 different ways, none of which are working (see image below in line 24,25,28, and 31)
This is how the rendering looks. Just a picture icon shows.
Here is the main page of the repository.
Inside the images folder.
Does anyone have any idea why that is happening? I insert an image from a website and it renders fine but not when called locally from the folders its located.
Given that the file path of the post.html file is michaelamay/projects/_layouts/post.html. If you are trying to access michaelamay/projects/images/img_forest.jpg, the path should be given as:
<img src="../images/img_forest.jpg">
This is because the 'images' folder is not under either 'projects/_layouts' or the root of the project structure.
For more information, you can check this link.
I have an HTML file, index.html, for my website, in a folder. This folder contains the index.html file, and another folder called "Stylesheets", with the stylesheet.css file inside. How do I link to it? I know how to do a link tag, but the href bit is giving me a bit of trouble. I've tried
href="../stylesheets/stylesheet.css"
and a few variants of it with the dots. Any ideas? I've tried a couple google searches but the question is a bit too complex to describe in a simple google query. Please Help!
Your path - href="../stylesheets/stylesheet.css" is basically doing the opposite of what you want.It's not going one folder further as you wish.
To accomplish what you want, you are going to have this path:
href="stylesheets/stylesheet.css"
Here you can read more about File Paths.
Use href="stylesheets/stylesheet.css" or href="./stylesheets/stylesheet.css"
Both mean the look for stylesheet.css file inside the stylesheet folder inside the current folder.