0

Can't link the page "index2.html"0 from the "rock-paper-scissors-game2" folder to "index.html" in the "digital-clock" folder. Not sure if the code is wrong or something else.

I'm using Atom by the way, and I don't know what else to try because the code for the link looks correct.

<a href="rock-paper-scissors-game2/index2.html"> Game </a>

And when I run it in chrome it gives the file not found error.

Your file was not found It may have been moved or deleted. ERR_FILE_NOT_FOUND

Scott Marcus
  • 64,069
  • 6
  • 49
  • 71
Paranoid
  • 25
  • 1
  • 8
  • 2
    It looks to me like you might have forgotten the forward slash for the folder. Try ` Game `. Depending on your site setup you might need a slash at the start too, or even a `../` or similar. I don't know, I can't see your folder structure or your server config – ADyson Jul 09 '19 at 23:34
  • ADyson's comment is a good start. If you have more trouble, you may want to check out [this question](https://stackoverflow.com/questions/908765/how-to-link-html-pages-in-same-or-different-folders) – ldtcoop Jul 09 '19 at 23:36

2 Answers2

2

To link to another file WITHIN your web site structure, you should use relative references. Relative means, relative to the currently loaded resource.

To access something in the same folder: Just use the file name:

<a href="file.html">Click Me<a>

To access something in a child folder: Start with the child folder name, a slash, and the file name:

<a href="childFolder/file.html">Click Me<a>

To access something starting at the root of your site, begin the path with a forward-slash:

<a href="/pathToFile">Click Me<a>

To access something in a parent folder, start with two dots and a forward-slash:

<a href="../file.html">Click Me<a>

To access something that is in a combination of the above, like a sibling folder, you need to go up to the parent and then down to the correct child:

<a href="../digital-clock/index2.html">Click Me<a>

As an initial test to make sure the file exists, temporarially place it in the same folder as the current page and see if the first example I showed works. If not, you've got a different issue than you think.

Next, you mention that index2.html is in the digital-clock folder, but you didn't reference that folder in your link, so make sure to include that. But, depending on where that folder is will dictate which method I've shown above you need to use.

Scott Marcus
  • 64,069
  • 6
  • 49
  • 71
-1

This should work <a href="../rock-paper-scissors-game2/index2.html">Game</a>

DaveAAA
  • 740
  • 7
  • 14