SHTML 的目的和独特性是什么?

发布于 2024-07-14 00:41:24 字数 91 浏览 11 评论 0原文

最近,当我看到一个带有 .shtml 扩展名的网站时,我开始了解 SHTML。

SHTML 的目的是什么?它与 HTML 和 DHTML 有何不同?

Recently I came to know about SHTML when I saw a site with .shtml extensions.

What is the purpose of SHTML, and in what ways does it differ from HTML and DHTML?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

神魇的王 2024-07-21 00:41:24

SHTML 是一种文件扩展名,可让 Web 服务器知道应使用服务器端包含 (SSI) 来处理该文件。

(HTML 是......你知道它是什么,DHTML - 动态 HTML - 是 Microsoft 对 Javascript+HTML+CSS 的名称)。

您可以使用 SSI 在页面中包含公共页眉和页脚,这样您就不必重复太多代码。 更改一个包含的文件会立即更新所有页面。 您只需照常将其放入 HTML 页面即可。

它嵌入在标准 XML 注释中,如下所示:

<!--#include virtual="top.shtml" -->

它已在很大程度上被其他机制(例如 PHP 包含)所取代,但某些托管软件包仍然支持它,仅此而已。

您可以在这篇维基百科文章中阅读更多内容。

SHTML is a file extension that lets the web server know the file should be processed as using Server Side Includes (SSI).

(HTML is...you know what it is, and DHTML - Dynamic HTML - is Microsoft's name for Javascript+HTML+CSS).

You can use SSI to include a common header and footer in your pages, so you don't have to repeat code as much. Changing one included file updates all of your pages at once. You just put it in your HTML page as per normal.

It's embedded in a standard XML comment, and looks like this:

<!--#include virtual="top.shtml" -->

It's been largely superseded by other mechanisms, such as PHP includes, but some hosting packages still support it and nothing else.

You can read more in this Wikipedia article.

差↓一点笑了 2024-07-21 00:41:24

它只是带有服务器端包含的 HTML。

It’s just HTML with Server Side Includes.

各自安好 2024-07-21 00:41:24

“既然已经是 2021 年了,我就要回答这个问题,因为最初的答案是从一个生活在 SSI 非常普遍的时代的人的角度回答这个问题的,然而,它们几乎已经过时了在当代网络开发中。”

“SSI 是缩写词:服务器端包含。”

“SHTML”,或(.shtml)只不过是一个简单的文件扩展名,用于向开发人员表示& 浏览器认为当前文档是一个“HTML 文档”,它实现了“服务器端包含”

我认为解释 SSI 的最佳方法是将它们与 C 语言进行比较(不要与C 样式语法混淆)。 C 语言成为一个很好的参考点的原因有两个:

  • A. 大多数上过计算机科学学校的软件/Web 开发人员至少“稍微”熟悉其中一种 C 语言(对我来说过去是,现在仍然是 C++)。

  • B. 该语法显然源自原始 C 语言,因为它与 C 语言中的 #include 语句完全相同。


现在,如果您熟悉 C 语言,您可能已经很清楚我所描述的内容了。

而且,如果我继续,我会说:

“它们是网页的预处理器指令,开发人员实施这些指令是为了保持代码干燥并保持一致的页眉和页脚,这些指令是通过标准 C 指令语法实现的(例如 #includes#ifdef#define#if 等...)

那么您可能确切地知道它们是什么。

如果您以前没有学过 C 语言,那么这段摘录适合您:

在 C 语言中,有语法语句,用于添加库、类、接口、模板等。 .,它们看起来像这样:

  • #include

  • #define

  • #undef

  • #ifdef

  • #ifndef

等等...

嗯,“简而言之”,在网页中实现了相同的语法通过“服务器端包含”,或SSI


  • <强>关键区别: C 指令用于程序中,SSI 则用于网站中。

  • 关键相似性 它们都是导入程序/网站要使用的代码。


SSI 如下所示:

<!--
 #include ifheader="reference-page" file="header.html" else="header-alt.html" 
-->

  • SSI 还具有 #if#else 等...

现在我们已经确定了 SSI 的外观及其语法,我将参考当代世界来解释它们是什么。

我是在2021 年中写这篇文章的,因此值得注意的是,据我所知,2012 年是 SSI 的最后一次更新;此外; 它们由 W3C 标准化。 今天我们真的不需要它们,因为我们拥有更强大的技术。 第一个是模板引擎(Pug、Handlebars 等,以及 Vue 和 React 等框架) )。 现在,如果您看到一个页面,并且它的扩展名为 SHTML,那么它很可能是一个旧页面,并且可能需要更新。 我发现并回答这个问题的原因是因为我的一位教授有一个使用 SSI 的网站,我注意到 Edge 无法正确加载它 - 标题落入文本正文中。 看到像 Edge 这样的新浏览器无法正确呈现一项已经过了鼎盛时期的技术,这是一个很好的迹象,表明该技术的支持正在下降,并且正在逐渐消失。 总结一下; 如果您看到“SHTML”文件扩展名 - ie foo.shtml - 您现在就知道它为什么在那里,现在您知道它是什么了,它就是在那里做的,

最后一点:

SSI 在 XHTML 时代非常重要。 但是,在当代的开发世界中,SSI 最好被用作老师或提醒,一种技术可以非常流行,并且标准化可以由一个以标准化有史以来最具体的 Web 技术而闻名的组织 (W3C) 来维护,但它仍然可以以罗马方式崩溃。 SSI 是一个好主意,但是 Web 是用 C++ 编写的语言编写的,而不是实际用 C++ (JavaScript) 编写的,这是有原因的。

"Since it is 2021, I am going to answer this, because the original answer answers the question from the perspective of a person who was living during a time that SSI's were very common, however, they are nearly obsolete in contemporary web development."

"SSI is an Acronym that abbreviates: Server Side Includes."

"SHTML", or (.shtml) is nothing more than a simple file extension used to denote to developers & browsers that the current document is an "HTML Doc", that implements "Server Side Includes".

I feel the best way to explain SSI's are to compare them to C-Languages (not to be confused with C-Style Syntax). The reason C-Languages make a good reference point is because of two reasons:

  • A. Most Software/Web-developers who have went to school for computer science are at least "somewhat" familiar with one of the C languages (for me it was, and still is C++).

  • B. The syntax was obviously dirived from the original C-language as its exactly the same as the #include statments in C languages.


So now if you are familiar with a C language you probably already have a good idea of what I am describing.

And, if I continue, and I say:

"They are pre-processor directives for webpages, that developers implement to keep their code DRY and maintain consistent headers and footers, which are implemented via the standard C-directives syntax (e.g. #includes, #ifdef, #define, #if, etc...)

Then you probably know exactly what they are.

If you haven't studied a C-language before, then this excerpt is for you:

In C languages, there are syntax statements, that are used for adding libraries, classes, interfaces, templates, etc.., and they look like this:

  • #include

  • #define

  • #undef

  • #ifdef

  • #ifndef

etc...

Well, "in a nut shell", that same syntax is implemented in webpages via "Server Side Includes", or SSI's


  • Key-Difference: Where C Directives are used in programs, SSI's are used in websites.

  • Key-Similarity They both import code to be used by the program/website.


SSIs look like this:

<!--
 #include ifheader="reference-page" file="header.html" else="header-alt.html" 
-->

  • SSIs also have #if, #else, etc...

Now that we have determined what an SSI looks like, as well as its syntax, I will explain what they are in reference to the contemporary world.

I am writing this in Mid 2021, so it is important to note, that as far as I can tell, 2012 was the last time SSIs were updated at all, furthermore; they are standardized by W3C. Today we really don't need them, because we have much more powerful technologies. The first being templating engines (Pug, Handlebars, etc..., and frameworks like Vue, and React). Now days, if you see a page, and it has the extension SHTML, its an old page most likely, and probably needs to be updated. The reason I found, and answered this question is because a professor of mine has a website that makes use of SSIs, and I noticed that edge doesn't load it properly — the header drops into the text body. Seeing a new browser like edge, not correctly rendering a technology that is well past its prime, is a pretty good sign that support is falling for that technology, and it is fading into the sunset. To conclude; if you see the "SHTML" file extension — i.e. foo.shtml — you now know why it is there, and you now know what it is, that it is, doing there,

Quick last note:

SSIs where big during the days of XHTML. But, in the contemporary Dev-World, SSI's are best utilized as a teacher, or reminder, that a technology can be extremely popular, and the standardization can be maintained by a group known for standardizing the most concrete web technologies ever created (W3C), and still it can crumble in a roman fashion. SSI's were a great idea, but there is a reason why the web is written in a language that is written in C++, and not actually written in C++ (JavaScript).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文