Websites provide a lot of web pages with different URLs but there are some defacto pages that exist most of the web sites. index.html
is one of them. index.html is used as the main or entrance page for the whole web site or web application.
网站提供了许多具有不同URL的网页,但是大多数网站上都存在一些事实上的页面。 index.html
是其中之一。 index.html用作整个网站或Web应用程序的主页或入口。
什么是index.html? (What Is index.html?)
As its name suggests index.html consists of two words index
and html
. The index simply means shortlist for multiple items. In web terminology generally used to showcase the website pages, categories or parts on a single page. Html simply an extension for the index file which means the index file is an HTML file that contains HTML code or tags with some CSS and JavaScript code. index.html file generally resides in the root path of the web page and when the web site like http://www.poftut.com
is requested by default index.html file is returned.
顾名思义,index.html由两个单词index
和html
。 该索引只是意味着多个项目的候选清单。 在网络术语中,通常用于在单个页面上展示网站页面,类别或部分。 HTML只是索引文件的扩展名,这意味着索引文件是一个HTML文件,其中包含HTML代码或带有一些CSS和JavaScript代码的标签。 index.html文件通常位于网页的根路径中,并且默认情况下,当请求http://www.poftut.com
之类的网站时,将返回index.html文件。
什么包含index.html? (What Contains index.html?)
As stated previously index.html file contains mainly HTML code or tag with some CSS and JavaScript code. The client web browser will render and show the HTML, CSS and JavaScript code. For example, the following screenshot is the https://www.apachefriends.org/index.html
. This is the main page of the apachefriends.org
which contains content like text, header, video, menus, categories, links etc.
如前所述,index.html文件主要包含HTML代码或带有一些CSS和JavaScript代码的标签。 客户端网络浏览器将呈现并显示HTML,CSS和JavaScript代码。 例如,以下屏幕截图是https://www.apachefriends.org/index.html
。 这是apachefriends.org
主页,其中包含诸如文本,标题,视频,菜单,类别,链接等内容。
![What Contains index.html?](https://i-blog.csdnimg.cn/blog_migrate/b8deba2e41803461561c2098862a3c5f.png)
index.html代码 (index.html Code)
There is no standard about the index.html code but there are some regular code parts generally used in index.html. Below we can see that the JavaScript code is defined inside the head part of the web page. Also, the links and menu are defined as the first element of the index.html.
关于index.html代码没有标准,但是index.html中通常使用一些常规代码部分。 在下面,我们可以看到JavaScript代码是在网页顶部定义的。 同样,链接和菜单被定义为index.html的第一个元素。
![index.html Code](https://i-blog.csdnimg.cn/blog_migrate/78c4a540592b4401f8c3084bfc7b70f8.png)
index.html基本结构(index.html Basic Structure)
When we look at an index.html file we can see that there is some basic structure that is mostly used in most of the web site’s other pages.
当我们查看index.html文件时,我们可以看到存在一些基本结构,该结构主要在大多数网站的其他页面中使用。
- `Menu` will contain shortcuts to other pages of the sites. “菜单”将包含指向网站其他页面的快捷方式。
- `Main Content` generally contains information about the web site and some latest or generic or definitive information about the web site. “主要内容”通常包含有关网站的信息以及有关该网站的一些最新或通用或权威性信息。
- `Footer` may contain some social media link, contact information, copyright information, etc. “页脚”可能包含一些社交媒体链接,联系信息,版权信息等。
index.html的位置 (Location Of The index.html)
The index.html file is stored inside the web site root directory of the webserver. If the webserver is Apache2 the default path is /var/www
and the web site folder name. If the webserver is IIS the path will be C:\inetpub\sites
by default but change according to specific web site configuration.
index.html文件存储在Web服务器的网站根目录中。 如果Web服务器是Apache2,则默认路径是/var/www
并且网站文件夹名称。 如果Web服务器是IIS,则默认情况下路径为C:\inetpub\sites
,但根据特定的网站配置进行更改。
index.html与index.htm (index.html vs index.htm)
Well, we can see some minor changes in the usage of the index.html web page. index.htm
is an alternative to the index.html file. index.htm is generally used in Windows servers but almost the same HTML, CSS and JavaScript code is used.
好吧,我们可以看到index.html网页的用法有一些小的变化。 index.htm
是index.html文件的替代方法。 index.htm通常在Windows服务器中使用,但是使用几乎相同HTML,CSS和JavaScript代码。
index.html替代方法 (index.html Alternatives)
index.html was popular a long time ago. Currently, most of the web sites prefer index.php
or nothing where index.html is not used. But there are some alternatives that are mostly used with dynamic server-side applications or sites like PHP , Python, ASP.NET, etc.
index.html很久以前就很流行。 当前,大多数网站更喜欢index.php
或不使用index.html的网站。 但是,有些替代方案通常用于动态服务器端应用程序或站点,例如PHP,Python,ASP.NET等。
- `index.asp` is used by ASP.NET web sites or web applications. ASP.NET网站或Web应用程序使用“ index.asp”。
- `index.php` is used by PHP web applications. PHP Web应用程序使用`index.php`。
- `default.html` or `home.html` are also alternatives to the index.html. default.html或home.html也是index.html的替代方案。
翻译自: https://www.poftut.com/what-is-index-html-how-to-create-and-use-index-html/