問題描述
我正在使用 HTML5,并希望通過將標準 HTML 模板拆分為三個單獨的 HTML 文件來加快創建和編輯的速度.
I am using HTML5, and would like to speed up the creation and editing of my standard HTML template by splitting it into three separate HTML files.
- header.html
- content.html(這將被編輯并具有其他名稱,例如 home)
- 頁腳.html
我查看了以下資源,但我不確定這是否可行或如何去做.
I have looked at the following resources, but I am not sure if this is possible or how to go about it.
http://www.w3schools.com/html/html_head.asp
http://www.w3schools.com/tags/tag_link.asp
在 PHP 中,我只會按正確的順序包含文件.在純 HTML 網站中是否有等價物?
In PHP I would just include the files in the right order. Is there an equivelant in just a plain HTML site?
我已經用谷歌搜索了這個,但我認為我沒有找到正確的術語.我將不勝感激任何可用的信息或資源!
I have googled this, but I don't think Im searching for the right term. I would appreciate any information, or resources available!
感謝您的寶貴時間!
推薦答案
對于一個靜態 HTML 站點,沒有 html-only 方法可以按照您嘗試的方式包含文件.您可能能夠使用服務器端包含,具體取決于您的服務器,但到那時,您還不如只使用 PHP.
For just a static HTML site, there is no html-only way to include files the way you are trying to. You may be able to use server-side includes depending on your server, but by that point, you might as well just use PHP.
另一種選擇是在頁面的主要部分已經加載后廣泛使用 Javascript 來加載頁面片段.
Another option would be to make extensive use of Javascript to load the page pieces after the main part of the page is already loaded.
但是,在所有情況下,性能都會大大降低,因為服務器請求很慢.如果您需要使用模板,只需使用 PHP 等動態語言即可.
In all cases, though, you will have a major reduction in performance, since a server request is slow. If you need to use templates, just use a dynamic language like PHP.
這篇關于拆分一個html頁面并通過標題加載它?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!