Live data from Hacker News

Why can't HTML alone do includes?

frontendmasters.com

101–110 of 367 posts

Re: Why can't HTML alone do includes?

#101
post #96

Earlier quoted context omitted.

HTML is a markup language, not a programming language. It's like asking why Markdown can't handle includes. Some Markdown editors support them (just like some server-side tools do for HTML), but not all.

Well, asciidoc - a markup language supports includes, so the "markup languages" analogy doesn't hold. https://docs.asciidoctor.org/asciidoc/latest/directives/incl...

[deleted]

Re: Why can't HTML alone do includes?

#102
This is just my own understanding, but doesn't a webpage consist of a bunch of nodes, which can be combined in any way. And an html document is supposed to be a complete set of nodes, so a combination of those won't be a single document anymore.

Nodes can be addressed individually, but a document is the proportion for transmission containing also metadata. You can combined nodes as you like, but you can't really combined two already packed and annotated documents of nodes.

So I would say it is more due a semantic meaning. I think there was also the idea of requesting arbitrary sets of nodes, but that was never developed and with the shift away from a semantic document, it didn't make sense anymore.

Re: Why can't HTML alone do includes?

#103
post #17

This was the rabbit hole that I started down in the late 90s and still haven’t come out of. I was the webmaster of the Analog Science Fiction website and I was building tons of static pages, each with the same header and side bar. It drove me nuts. So I did some research and found out about Apache server side includes. Woo hoo! Keeping it DRY (before I knew DRY was a thing). Yeah, we’ve been solving this over and ove…

The optimal solution would be using a template engine to generate static documents.

Re: Why can't HTML alone do includes?

#104

This is just my own understanding, but doesn't a webpage consist of a bunch of nodes, which can be combined in any way. And an html document is supposed to be a complete set of nodes, so a combination of those won't be a single document anymore. Nodes can be addressed individually, but a document is the proportion for transmission containing also metadata. You can combined nodes as you like, but you can't really comb…

I think the quickest way to say it is that there is only one head on a page, and every HTML file needs a head. So if you include one into the other, you either have two heads, or the inner document didn't have a head.

Re: Why can't HTML alone do includes?

#105
post #97

Earlier quoted context omitted.

That’s the Hyper part of HTML, and what makes it special. It’s made to pull in external resources (as opposed to other document formats like PDF). Scripts, stylesheets, images, objects, favicons, etc. HTML is thematically similar.

No, HTML is fundamentally different because (for a static site without any JS dom manipulation) it has all the semantic content, while stylesheets, images, objects, etc. are just about presentation.

Iframes exist.

Re: Why can't HTML alone do includes?

#106
post #17

This was the rabbit hole that I started down in the late 90s and still haven’t come out of. I was the webmaster of the Analog Science Fiction website and I was building tons of static pages, each with the same header and side bar. It drove me nuts. So I did some research and found out about Apache server side includes. Woo hoo! Keeping it DRY (before I knew DRY was a thing). Yeah, we’ve been solving this over and ove…

HTML is a markup language, not a programming language. It's like asking why Markdown can't handle includes. Some Markdown editors support them (just like some server-side tools do for HTML), but not all.

Markdown doesn't have this common HTML pattern of wanting to include a header/footer in all pages of a site.

Re: Why can't HTML alone do includes?

#110
I'd say in 80% of the cases a pure, static html include is not enough. In a menu include, you want to disable the link to the currently shown page or show a page specific breadcrumb. In a footer include, you may want a dynamic "last updated" timestamp or the current year in the copyright notice. As all these use cases required a server-side scripting language anyway, there was no push behind an html include.
Post reply on HN