在HTML中创建模板的最佳实践 [英] Best practice to create a template in HTML

查看:142
本文介绍了在HTML中创建模板的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始用纯HTML创建网页。我有一个标题,主要内容和页脚。主要内容分为左右两个内容。除了正确的内容以外,所有页面上的所有内容都是相同的。现在我有大约15页。如果我在其他静态页面(页眉,页脚和左侧内容)上进行一些更改,这是非常烦人的,因为我必须浏览所有页面。

I started creating web pages in plain HTML. I have a header, main content and a footer. The main content is divided into two, left and right content. Everything is the same on all pages except for the right content. Now I have about 15 pages. This is very tiresome if I make some changes on the other static pages (header, footer and left side content) as I have to go through all pages.

为每个静态区域创建一个HTML文件的最佳方式是什么,以及如何整合它?

What is the best way to create one HTML file for each static area and how am I going to integrate it?

推荐答案

有两种方法可以做到这一点。

There are a couple of ways to do this.

如果纯粹使用HTML,那么您可以使用'服务器端包含' - 这是一个允许您将文件加载到页面中的标签(请参阅 http://en.wikipedia.org/wiki/Server_Side_Includes )。无论谁托管你的网站都必须支持这一点。

If you are working purely with HTML, then you can use a 'server side include' -- this is a tag which allows you to load a file into the the page (see http://en.wikipedia.org/wiki/Server_Side_Includes). Whoever is hosting your website has to support this.

<!--#include virtual="../quote.txt" -->

如果您的web主机恰好使用PHP,您可以使用include方法执行此操作(请参阅 http://php.net/manual/en/function.include.php ):

If youe web host happen to use PHP, you can do this using the include method (see http://php.net/manual/en/function.include.php):

<?php include('path_to_file/file.htm');?>

这将在放置标记的位置包含文件。但是,无论是谁托管你的网站需要支持这一点。

This will include the file at the point you place the tag. But again, whoever is hosting your site needs to support this.

还有其他的方法,这些是我使用的两个。

There are other methods of doing this, bit these are the two I make use of.

这篇关于在HTML中创建模板的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆