HTML包含:单独的页眉和页脚 [英] HTML Include: Separate Header and Footer

查看:363
本文介绍了HTML包含:单独的页眉和页脚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们是否可以包含来自另一个HTML文件的HTML文件/代码片段?



我的用例与网站的构建方式有关;在一个简单的形式中,一个站点通常具有相同的页眉和页脚。如果网站配备了例如网站,那么这非常简单。 PHP,所以你可以做一些像 include 声明;我们可以在不同的文件中包含页眉和页脚,并在稍后添加它们。但是,如果该网站纯粹是静态的,即没有后端支持,该怎么办?



过去我做过的一件事是利用模板。这工作,但我宁愿更独立于产品的东西。



谢谢。

解决方案

您正在寻找的是服务器端包含。它曾经在大多数主机上都可用,不知道现在情况如何。

实际上,一个基于makefile的简单系统以及为什么不是php的命令行版本,也可能是有帮助的:一个简单的makefile,访问目录中的所有php文件,将它提供给php(例如,处理页面装饰和东西),并将输出重定向到相应的html文件应该足以生成一组可上载, 100%静态HTML文件。


Can we include an HTML file / snippet from another HTML file?

My use case is related to how a website is built; in a simple form, a site typically has the same header and footer across the board. It is pretty straightforward if the site is equipped with e.g. PHP so you can do something like the include statement; we can contain the header and footer in separate files and include them later. But, what if the site is purely static i.e. no "back-end" support?

One thing that I had done in the past is to utilize templates in Dreamweaver. This worked but I'd prefer something that is more product-independent.

Thanks.

解决方案

What you're looking for is Server Side Includes. It used to be available on most hostings, no idea what the situation is today.

Actually, a simple system based on a makefile and, why not, php's command line version, might also be helpful: a simple makefile that visits all php files in a directory, feeds it to php (eg, processes page decoration and stuff) and redirects the output to a corresponding html file should be enough to generate a set of uploadable, 100% static html files.

这篇关于HTML包含:单独的页眉和页脚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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