首页 > 解决方案 > HTML 中的内部链接

问题描述

我有很多内部链接要用于我正在构建的第一个网站。当我在本地运行它时效果很好,但在实际站点上没有任何内部链接起作用。例如,这是我正在使用的一个内部链接。

<a href ="file:///C:/Users/17249/OneDrive/Dive%20Platform/National%20Popular%20Vote.html">Read More</a>

我明白为什么这不起作用,但如果一个链接还不存在,我可以放什么链接?我想如何为我的网站创建子页面?

提前致谢!

标签: htmlcss

解决方案


您可以在每个页面中放置相对链接。让我们假设您的网站层次结构是这样的:

index.html  

category-a.html  
category-a/page1.html  
category-a/page2.html

category-b.html  
category-b/page1.html
category-b/page2.html

The link from index.html to category-a.html would be: 
<a href="./category-a.html">category a</a>

The link from category-a.html to category-a/page1.html would be: 
<a href="./category-a/page1.html">page 1 of category a</a>

The link from category-a/page1.html to index.html would be:
<a href="../index.html">Home</a>

推荐阅读