Hacker News new | ask | show | jobs
by sabellito 549 days ago
I do that. Duplicating the header, menu, and footer manually on every page is a pain in the ass. Not to mention the lack of minification.
5 comments

Not sure I follow, do you not use templates and scripts to generate the static pages?

I was a web developer 25 years ago and for the majority of projects we only made static sites, all templated and minified. My skills are somewhat "of that time".

Recently I was asked to build a site to demonstrate some new software. It consisted of over 10k pages that once built would rarely, if ever be updated.

I just scripted and templated the generation of every single page hosted it in S3. This may sound ridiculous in this day and age but it takes a few minutes to rebuild and update the entire site.

Guess my point is I don't really find duplicating things to be a pain in the ass

I don’t think it sounds ridiculous, it sounds like you picked the right tool for the job. Don’t bring dynamic solutions to static problems…
What the grandparent comment was referring to was eschewing static site generators in favor of entirely handmade html and css. The person you’re responding to was arguing in favor of static site generators for the reasons they listed. I was advocating for a simpler breed of SSGs than we have now for simple tasks, and this project seems to fit that niche. Most SSGs these days are only trivial if you’ve got current web developer knowledge at your finger tips.
Yes, that's what I meant.
That isn’t ridiculous and is in fact how the bulk of modern static site generators work. Hugo, Jeykll, Astro (the one I use), etc.
I think this issue better addressed in HTML spec. Basic functionality to include html snippets files in other HTML files should be standard. What am I missing?
Well, the HTML spec is missing that, has been for decades despite people asking for it, and to my knowledge has never even made it to a roadmap.
How would that work? Now one request for a page becomes N requests for every bit of HTML the client needs to render?
That’s sorta the case with frames and asynchronously loaded stuff anyway though right? I think they just consider the problem solved in practice through scripting and frames. Besides, HTML doesn’t have room for that— they need room for all the features nobody uses and cares about. XD I’ve been writing HTML to some extent for 30 years and I periodically come across shit— not even new shit— that I swear I’ve never even heard of.
> That’s sorta the case with frames and asynchronously loaded stuff anyway though right?

Yeah, and that's not something to emulate. And if so, it sort of already exists in the spec: iframe.

I’m not sure how it could possibly make the problem worse if the problem is already endemic to modern websites in a form far more heavily used than that ever would be.
You could cache the intermediate bits. Hell you could do this right now (somewhat) by doing script src=menubar.js and the script containing document.write calls. Not great for performance.
Wouldn't that just ends up re-inventing XML and <xsl:include> ?
It is - it is called frames.
Serverside includes are a thing in Apache or nginx.

If you don’t mind a little coding, it wouldn’t take long to build a tool that lets you store the bodies as template files, wraps them in the header/footer, and minifies them.

Even less effort is pandoc’s standalone mode which lets you provide a wrapper template.

Yeah SSI solved this 30 years ago. It's kind of a fire and forget solution too.
Why do you care if your personal site is minified?
Because some people care about low-bandwith users. Or about not being wasteful as a principle.
Doesn't compression make any minification gains negligible?
Depends on what you’re serving up. Blog? Yes. Video game? No.
You can just have git submodules for that.