Home > Enterprise >  how to properly link source in html inside folders?
how to properly link source in html inside folders?

Time:08-14

i have multiple folders with other htmls, i want to link them all between each other.

folder structure looks like this:

Main Folder
   index.html
   nav.js
   Project Folder
      project1.html
      project2.html
   images
      image1.png
      image2.png
 

this is how i try to link:

  1. index.html: <a href="/Project Folder/project1.html"></a> <a href="./Project Folder/project1.html"></a>
  2. project1.html: <a href="/index.html"></a> <img src="./images/image1.png> <script src="./nav.js">

it works with visual code live, but doesn't work when i open just index.html. i get error for not loading neither image or script, and when i press on a i get another error of page not found.

i want to figure out what is proper way of linking items inside multiple folders and in which case i have to use "./" or "/" and if there is anything else.

CodePudding user response:

you need to use template engine like PUG.JS

CodePudding user response:

you don't need a / bc they are in the same file "main folder"

unless if the file is deeper then the index file then do Project Folder/file

  • Related