如何在 HTML 中创建模板? [英] How to create a template in HTML?

查看:62
本文介绍了如何在 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 文件以及如何集成它?

How can I 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 page (see http://en.wikipedia.org/wiki/Server_Side_Includes). Whoever is hosting your website has to support this.

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

如果您的网络主机碰巧使用 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天全站免登陆