簡體   English   中英

如何使用 html 文件鏈接到另一個 html 文件?

[英]How do I use a html file to link to another html file?

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>

上述 html 文件位於名為 templates 的文件夾中。

在模板中,我有另一個名為 homepage_photos 的文件夾。

在 homepage_photos 我有一個名為 test.html 的 html 文件

考慮當我查看 homepage_template.html(在我的網站上)時,我的 URL 看起來像這樣 - “mywebsite”

每當單擊鏈接時,URL 將 go 到 mywebsite/homepage_photos/test.html 而不是僅僅轉到文件本身

旁注:我正在使用 Django

您在 href arribute 中犯了一個錯誤。 您是說所有文件都在一個文件夾中,而所需的路徑在另一個文件夾中。 所以你應該在描述路徑之前使用 / :

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

根據文件的組織方式,您的路徑可能不正確。 如果您只是簡單地命名文件(例如homepage_photos/test.html ),那么它僅在homepage_photos與此 html 文件位於同一文件夾中時才有效。 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原始文件夾(可能包含您的index等)(請注意,使用 Github 頁面托管時,以/開頭的效果不佳)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM