How to leave transferable html between computers without losing hyperlink and images?

-1

I started programming a short time using HTML and my biggest problem is to do a project and when I take it to other computers it takes a lot of time changing the paths of images and hyperlinks.

How do I keep links from breaking when I take my project to another computer?

Example, on the pc of my company the link is something like:

  

D: \ Users \ Scheduler \ Desktop \ my-project \ images \ logo.png

On my pc it stays

  

C: \ Users \ Joao \ Desktop \ my-project \ images \ logo.png

    
asked by anonymous 01.09.2017 / 18:21

2 answers

5

To avoid or minimize this type of problem you can use relative paths.

To refer from the "folder" to which the file was opened, start the path without bars, for example:

You have the following structure:

  • index.html
  • images (folder)
    • logo.png
  • otherfile.html
  • people (folder)
    • person.html

Your img tag would look like:

<img src="imagens/logo.png">

Your hyperlink would look like:     Another file

The image in the file pessoa.html would have to "back" a folder to find the files, for example:

<img src="../imagens/logo.png">

You can find more detail at this link: link

    
01.09.2017 / 18:59
0

The real problem is you use absolute paths to map your resources in Html, I recommend using relative paths, so when switching machines the problem will not exist

In your case, if the Html file is in the D:\Users\Programador\Desktop\meu-projeto\ folder, the page path can only be images\logo.png , the system will search the% regardless of where the images folder is

    
01.09.2017 / 18:57