Hyperlink? Question.

Discussion in 'HTML & Website Design' started by Web_Dev_Chris, Jun 9, 2016.

  1. #1
    I'm writing HTML in notepad and when I upload my files to a server I need to reset the image links, download links ect...?

    Example, Download link is <a href="C:/Download/cool.pdf">Download Me</a>

    When uploaded to a server the location remains the same but has a new location on the server file?

    Is there an easier solution that changing that the links once the site is uploaded?

    Thanks.
     
    Solved! View solution.
    Web_Dev_Chris, Jun 9, 2016 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,807
    Likes Received:
    4,534
    Best Answers:
    123
    Trophy Points:
    665
    #2
    You would be better to have your local folder structure the same on your computer and the website.

    Then your code could be something like
    <a href='../Download/cool.pdf'>Download Me</a>
    Code (markup):
     
    sarahk, Jun 9, 2016 IP
  3. Web_Dev_Chris

    Web_Dev_Chris Well-Known Member

    Messages:
    222
    Likes Received:
    12
    Best Answers:
    1
    Trophy Points:
    105
    #3
    Thanks, that is helpful. Although, there isn't really a way around editing them once upload? There isn't a way to make it automatically update?
     
    Web_Dev_Chris, Jun 9, 2016 IP
    mmerlinn likes this.
  4. #4
    • I used to have code in my files that would check to see if it was live or on my pc and would write the hyperlink differently but it wasn't a good practice.
    • You could also write a javascript script that went through the links on the page and converted them
    but it's much better to do it once, and do it right.
     
    sarahk, Jun 9, 2016 IP
  5. Web_Dev_Chris

    Web_Dev_Chris Well-Known Member

    Messages:
    222
    Likes Received:
    12
    Best Answers:
    1
    Trophy Points:
    105
    #5
    Thank you for your informative response.

    Regards,
    Chris
     
    Web_Dev_Chris, Jun 9, 2016 IP
  6. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #6
    The "smart way" is to set up a local server on your machine, for development. That way you can create the exact same file-structure on the local server as you have on the actual site, and therefore avoid having any issues. Using relative paths for links and such, you'll never have to worry about this.
     
    PoPSiCLe, Jun 10, 2016 IP
    KewL likes this.