1
<a href="folder1/index.html">Home Page</a>

I used this instruction in my code to link another code in another folder but when I test and press Home Page it doesn't work !

  • How does your application folder structure look like? Maybe the path you are using is not correct. The link above should work – Gitau Harrison Dec 10 '20 at 17:37
  • in my desktop i have a folder named myFolder containing two folders : folder1 (which contains index.html) and folder2 (which contains the file of this instruction's code) – Bacim OUESLATI Dec 10 '20 at 17:40
  • does this work `Home Page`? – l3est Dec 10 '20 at 17:42
  • Does this answer your question? [How do I link back out of a folder using the a-href tag?](https://stackoverflow.com/questions/20599870/how-do-i-link-back-out-of-a-folder-using-the-a-href-tag) – l3est Dec 10 '20 at 17:51

4 Answers4

0

Make sure your folder's name true or file path is true, if all of them is true try Home Page

0

Your code is: <a href="folder1/index.html">Home Page</a>;

Lets understand what it does. This code must be in some file. Lets say you are double-clicking a file myFile.html and this code is written inside it.

Now, this line says that at the very same location you have got a folder named - folder1 and inside it, there lies a file index.html. So, the structure would be like.

enter image description here

Now, if the path is correct, your file will open. There is nothing wrong in the code you have written.

You got 2 folders, each have got 1 files

Now, for your issue, first you need to go 1-space up and then go to the other folder. To go 1-place-up we use ../ instruction.

So, for you the answer would be:

<a href="../folder1/index.html">Home Page</a>

Deadpool
  • 7,811
  • 9
  • 44
  • 88
  • in my desktop i have a folder named myFolder containing two folders : folder1 (which contains index.html) and folder2 (which contains the file of this instruction's code) ... So how should the instruction be instead ? – Bacim OUESLATI Dec 10 '20 at 17:41
  • @BacimOUESLATI - I've updated the answer. Check it out. – Deadpool Dec 10 '20 at 17:52
0

based on the comments this is the folder structure you are using:

-myFolder
--folder1 (contains index.html)
--folder2 (contains the code you wrote)

to link from folder2 to folder1 you need to use ../ like this:

<a href="../folder1/index.html">Home Page</a>
l3est
  • 407
  • 2
  • 4
  • 16
0

With your structure looking as this:

myFolder
   |
   |----------folder1
                 |
                 |-----------> index.html
   |
   |----------folder2
                 |
                 |-----------> another_file.html

To link index.html from another_file.html, you need to carefully note the path from folder2 to folder1. You will need to do this in another_file.html to create that link:

<a href="../folder1/index.html">Home Page</a>

The ../ allows you to access the folder above your current location, which is folder2

Gitau Harrison
  • 3,179
  • 1
  • 19
  • 23