Home > OS >  How do I use a html file to link to another html file?
How do I use a html file to link to another html file?

Time:11-25

homepage_template.html

<!DOCTYPE html>
<html lang="en">
<head>




    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta charset="utf-8">
    <meta name="keywords" content="HTML, CSS">
    <meta name="description" content="My programing resume in the form of a django project built from scrarch">
    
     

    <title>Resume Homepage</title>


</head>


<body>
   <h1>Welcome To My Django Resume Webpage !&copy;</h1>

   <img src="main_photo.jpg" alt="Image Unable To Be Displayed">
   <p  </p>

   <h2>Coding Projects </h2>

   <a href="homepage_photos/test.html"> text!</a>


</body>


</html>

The above html file is located in a folder named templates.

In templates I have another folder named homepage_photos.

In homepage_photos I have a html file called test.html

Consider when I'm viewing homepage_template.html (on my website) that my URL looks like this - "mywebsite"

Whenever the link is clicked the URL would go to mywebsite/homepage_photos/test.html instead of just going to the file itself

Side note: I'm using Django

CodePudding user response:

You have done one mistake in href arribute. You are saying that all your files are in one folder and the desired path is in another folder. So you should use / before describing the path like this:

<a href="/homepage_photos/test.html"> text!</a>

CodePudding user response:

Your pathways may be incorrect based on the way that your files are organized. If you simply name the file (ex. homepage_photos/test.html) then it will only work if homepage_photos is in the same folder as this html file. In order to go back a folder you can lead the pathway with ../ (ex. ../homepage_photos/test.html will go back one folder before looking for homepage_photos. Lastly you can also lead with / in order to start in the original folder (where your index or the like is likely contained) (note that leading with / does not work well when using Github Pages to host)

  •  Tags:  
  • html
  • Related