Apache has supported Server Side Includes forever. All you need to do is drop an 'include' in your HTML file and Apache will inject the contents in the right place.
<!--#include virtual="/header.html" -->
I don't know for certain but suspect other webservers will have similar functionality.https://httpd.apache.org/docs/current/howto/ssi.html
Edit:
IIS: https://docs.microsoft.com/en-us/iis/configuration/system.we...
Lighttpd: https://redmine.lighttpd.net/projects/1/wiki/docs_modssi
Nginx: https://nginx.org/en/docs/http/ngx_http_ssi_module.html
Tomcat: https://tomcat.apache.org/tomcat-7.0-doc/ssi-howto.html
An iframe with some CSS might however work to some degree.
Or you could use a frameset
Everything in the XML "ecosystem" (XSL, XPath, XDT, SOAP) is so unfriendly that I'm no longer surprised everyone is reinventing these concepts in (unfortunately) JSON these days.
Resorted to using the DTD schema as it can support complex things (and that’s what they use for the probably never to be released updated version) through some python hackery to generate a hundred or more classes that takes forever to compile and, strangely enough, actually does what its supposed to do which is represent SVG as a bunch of classes with reading/writing to xml.
I was going through a phase and tried that with rss but it was more hassle than it was worth.
—edit—
Should add the DTD makes things like enums for tags or whatever simple so you can have typed values and property formed xml documents — can’t remember if I ever managed to get that working with the XSD.
If I received your code I would start by rolling my eyes, then by wasting some time learning Yet Another Technology (TM) that I will likely forget before the next time it comes handy.
In my experience, if you care about maintenance, one should stick to the worn path unless they have a good reason not to.
> It's cool that Apache also supports conditionals.
<...shudders...>
I wouldn't suggest using it for anything complex but it's ideal for inserting common headers and footers into static HTML.
Plus, it's using fewer technologies than anything you suggest. Less to maintain, less to go wrong. Sounds like a winner.
(didn't downvote you - I actually appreciate your sharing of your point of view)
{{include "/includes/header.html"}}
No JS, no external build step, still static HTML files -- just pieced together by the server at request-time. Works great [1]. (Or use plain Markdown, and have Caddy's template engine render it as HTML on-the-fly. Your choice.)[0]: https://caddyserver.com/docs/modules/http.handlers.templates
[1]: https://github.com/caddyserver/website/blob/master/src/docs/... <-- Try doing that with SSI
That aside, Caddy is awesome, thanks for a great piece of software!
$(document).ready(function() {
$('nav').load('/nav.html');
});
That's...it.Note, the people in the article were burned by wiki software that went unmaintained during its rewrite from Python 2.7 to Python 3 (afaict). Now they are editing HTML files on a production server. I'm sure getting let down like they did gave them a specific distaste for certain trade-offs that work for the rest of us, but you can also imagine the babies being thrown out with the bathwater like scaling out an article database without revision history.
That said, it tends to be a good thing when you realize a vastly simple solution works for you.