Html 如何在网站上创建子页面?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24543101/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 02:10:22  来源:igfitidea点击:

How to create a subpage on a website?

htmlcsswebfile-structure

提问by Calico

Let's say I have a website http://www.example.com

假设我有一个网站http://www.example.com

I want to create more subpages to this page i.e.

我想为此页面创建更多子页面,即

www.example.com/faq

www.example.com/faq

www.example.com/contact

www.example.com/contact

etc.

等等。

I'm pretty new to web design and my current knowledge extends to making basic websites using HTML, CSS, and a little JS.

我对网页设计很陌生,我目前的知识扩展到使用 HTML、CSS 和一点 JS 制作基本网站。

采纳答案by Gust van de Wal

You'll need to create new HTML files called faq.html and contact.html for this instance. Then you can link to these pages with <a>tags

您需要为此实例创建名为 faq.html 和 contact.html 的新 HTML 文件。然后你可以用<a>标签链接到这些页面

回答by Michael Aaron Safyan

This depends entirely on your web server. Your webserver is responsible for routing URL paths to the actual content to display. However, if you just have static HTML files (professional websites tend to have HTML templates in some templating language that gets filled in with data from databases and other sources using some server-side programming language and a templating engine), most web servers will, using the default configuration, route a subpath to the "index.html" file in a directory of the same name as the path. However, this is something that does vary from web server to web server and from configuration to configuration.

这完全取决于您的 Web 服务器。您的网络服务器负责将 URL 路径路由到要显示的实际内容。但是,如果您只有静态 HTML 文件(专业网站倾向于使用某种模板语言的 HTML 模板,这些模板会使用某些服务器端编程语言和模板引擎来填充来自数据库和其他来源的数据),大多数 Web 服务器都会,使用默认配置,将子路径路由到与路径同名的目录中的“index.html”文件。但是,这确实因 Web 服务器和 Web 服务器以及配置而异。

In other words, for a simple website, this will usually suffice:

换句话说,对于一个简单的网站,这通常就足够了:

website_folder/
   index.html <- this is the homepage
   faq/
     index.html <- this is served from "/faq" and from "/faq/index.html"
   contact/
     index.html <- this is served from "/contact" and "/contact/index.html"

However, for a professional website, you'll find something like this to be more common:

但是,对于专业网站,您会发现这样的情况更为常见:

website_folder/
  templates/
    homepage.tpl <- an HTML template in some templating system.
    faq.tpl         Examples of templating engines include Jinja2,
    contact.tpl     Django, CTemplate, though there are many, many others
  static/
  config/
  lib/
  src/
  ...

Where the webserver program (in this case I'm assuming it's under "src", but the exact organization of the code varies widely from one company to another or from one project to another) registers handlers for these different paths and the handlers are programmed to fill the corresponding templates.

网络服务器程序(在这种情况下,我假设它在“src”下,但代码的确切组织因公司而异或从一个项目到另一个项目)为这些不同的路径注册处理程序,并且处理程序被编程填写相应的模板。

回答by siabaJS

you just create another html file with the content you need and link it using an "a" tag

您只需使用您需要的内容创建另一个 html 文件并使用“a”标签链接它

<a href="about.html">about</a>

<a href="about.html">about</a>