"Includes" functionality is considered to be server-side, i.e. handled outside of the web browser. HTML is client-side, and really just a markup syntax, not a programming language. As the article says, the problem is a solved one. The "includes" issue is how every web design student learns about PHP. In most CMSes, "includes" become "template partials" and are one of the first things explained in the documentation. T…
I think it feels off because an HTML file can include scripts, fonts, images, videos, styles, and probably a few other things. But not HTML. It can probably be coded with a custom element ( ). I would be surprised if there wasn't a github repo with something similar.
Why can't HTML alone do includes?
281–290 of 367 posts
Re: Why can't HTML alone do includes?
#282I too lamented the loss of HTML imports and ended up coming up with my own JavaScript library for it. https://miragecraft.com/blog/replacing-html-imports At the end of the day it’s not something trivial to implement at the HTML spec/parser level. For relative links, how should the page doing the import handle them? Do nothing and let it break, convert to absolute links, or remap it as a new relative link? Should the…
Re: Why can't HTML alone do includes?
#283Re: Why can't HTML alone do includes?
#284This 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…
https://developer.mozilla.org/en-US/docs/Web/API/Service_Wor...
Re: Why can't HTML alone do includes?
#285Fun fact: this does work with iframes: about contact The important part is that the target iframe must have a `name` attribute (not identified by `id`.) I guess, this is a legacy of framesets & frames. (Of course, this has all the issues of framesets, as in deep linking, accessibility, etc.)
You have to give an iframe a specific height in pixels. There is no “make this iframe the height its content wants to be (like normal HTML).
This leads to two options:
- your page has nested vertical scroll bars (awful UX) - you have to write JavaScript inside and outside the frame to constantly measure and communicate how tall the frame wants to be.
Or you could just not use frames.
Re: Why can't HTML alone do includes?
#286This 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…
> a webpage consist of a bunch of nodes, which can be combined in any way More or less, but manipulating the nodes requires JavaScript, which some people would like to avoid.
Re: Why can't HTML alone do includes?
#287This 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…
Don't Service Workers API provide this now, essentially act like a in-browser proxy to the server. https://developer.mozilla.org/en-US/docs/Web/API/Service_Wor...
Re: Why can't HTML alone do includes?
#288On topic: what's the absolute minimal static site generator that can achieve this feature? I know things like Pelican can do it but it's pretty heavy. C preprocessor probably can be used for this...
Re: Why can't HTML alone do includes?
#289Earlier quoted context omitted.
It's too bad we didn't go down the XHTML/semantic web route twenty years ago. Strict documents, reusable types, microformats, etc. would have put search into the hands of the masses rather than kept it in Google's unique domain. The web would have been more composible and P2P. We'd have been able to slurp first class article content, comments, contact details, factual information, addresses, etc., and built a wealth…
I don't think there was ever a sustainable route to a semantic web that would work for the masses. People wanted to write and publish. Only a small portion of people/institutions would have had the resources or appetite to tag factual information on their pages. Most people would have ignored the semantic taxonomies (or just wouldn't have published at all). I guess a small and insular semantic web is better than no s…
In my experience trying to work with wikidata taxonomies, it can be a total mess when it's crowdsourced, and if you go to am "expert" derived taxonomy there are all kinds of other problems with coverage, meaning, democracy.
I've had a few flirtations with the semantic web going back to 2007 and long ago came to the personal conclusion that unfortunately AI is the only viable approach.
Re: Why can't HTML alone do includes?
#290HTML was historically an application of SGML, and SGML could do includes. You could define a new "entity", and if you created a "system" entity, you could refer to it later and have it substituted in. ]> .... &myheader; SGML is complex, so various efforts were made to simplify HTML, and that's one of the capabilities that was dropped along the way.
It existed also in DTD (Document Type Definition) used with HTML 4 and below, and XML. Came fromn SGML too I guess.