News for hackers. Stuff that matters.
Re:Rewriting my website in plain HTML and CSS by mirkodrummer on Tuesday January 14, 2025 @07:05PM (#42705693)
Nice job! If only HTML had a serious templating system(no the template tag isn’t enough) that could be used without JavaScript, we won’t need any 3rd party system for assembling static sites. For example a mechanism for including partials with the <link> tag and refer them inside a <template> or directly into current html
Re:Rewriting my website in plain HTML and CSS by ZYbCRq22HbJ2y7 on Tuesday January 14, 2025 @07:13PM (#42705754)
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/if...

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/po...

https://en.wikipedia.org/wiki/Server_Side_Includes

Also, other than to satisfy a purist desire, why do you need this?

You can pre-render HTML quickly using a variety of template systems, and it would outperform what you are suggesting every time (from a client's perspective). I mean, think about the potential CSS resolution complexity, FOUC, etc.

Re:Rewriting my website in plain HTML and CSS by recursive on Tuesday January 14, 2025 @07:13PM (#42705757)
In the 90s, we used Server Side Includes (SSI) for this. Probably still works.
Re:Rewriting my website in plain HTML and CSS by skyfaller on Tuesday January 14, 2025 @07:26PM (#42705855)
One modern approach would be Caddy Server's templates, using Golang templating:

https://caddyserver.com/docs/modules/http.handlers.templates

The "include" function should do the job:

{{include "path/to/file.html"}}

Re:Rewriting my website in plain HTML and CSS by ZYbCRq22HbJ2y7 on Tuesday January 14, 2025 @07:34PM (#42705917)
httpd, nginx, a number of other servers support SSI

https://nginx.org/en/docs/http/ngx_http_ssi_module.html

Caddy chose not to, I guess?

https://caddy.community/t/caddy-update-on-ssi-server-side-in...

Re:Rewriting my website in plain HTML and CSS by alwillis on Wednesday January 15, 2025 @01:35AM (#42708019)
You generally can’t use SSI on many popular platforms for static websites like Netlify, etc.
Re:Rewriting my website in plain HTML and CSS by someothherguyy on Wednesday January 15, 2025 @02:53AM (#42708465)
However, you could generate the static HTML easily and then publish it on those platforms, which is what many people do today (probably not often using SSI).
Re:Rewriting my website in plain HTML and CSS by Gualdrapo on Tuesday January 14, 2025 @07:25PM (#42705850)
(Chiming in because other people replying to you kept on the "iframe-like" part of the argument)

Or serializing `<template>`s without needing JS. Like in lists (`<ol>`, `<ul>`, `<dl>`...). All in all `<template>`s are a nice thing to have, and I do use them a lot (like in my own portfolio), but it feels really lacking without JS.

Re:Rewriting my website in plain HTML and CSS by nigel182 on Tuesday January 14, 2025 @07:22PM (#42705820)
We've got frames and iframes...
Re:Rewriting my website in plain HTML and CSS by campak on Tuesday January 14, 2025 @07:25PM (#42705851)
You could use HTMX.org ;)
Re:Rewriting my website in plain HTML and CSS by morcus on Tuesday January 14, 2025 @07:54PM (#42706050)
Does HTMX work without Javascript?
Re:Rewriting my website in plain HTML and CSS by recursive on Tuesday January 14, 2025 @09:55PM (#42706788)
They wrote the javascript so you don't have to.
Re:Rewriting my website in plain HTML and CSS by mixmastamyk on Tuesday January 14, 2025 @08:27PM (#42706251)
I mentioned the object tag elsewhere: https://news.ycombinator.com/item?id=42706227