Will I figure out how to add boilerplate HTML to static HTML files before close?
4
100Ṁ288
resolved May 7
Resolved
YES

My website is a plain HTML website, using Express to serve files. I want to have a single file that includes some boilerplate HTML, which then gets inserted into each HTML file that gets served, similar to a PHP include statement.

You'd this think would be simple, but no. I've spent hours on this and was unable to find a single tutorial or StackOverflow answer that addresses this. It's always "here's how to set up an entirely new website with EJS/Handlebars/Pug, no I'm not going to explain how to adapt an existing website to use them without changing anything else" or "write custom middleware for Express that allows you to perform arbitrary string replacements, no I'm not going to explain how to do that". And of course EJS appears to just have no official documentation whatsoever.

I think independent blogs have gotten so rare that nobody expects this is a thing anyone is trying to do anymore. Plz help.

I would accept any of:
Custom middleware for Express that lets me perform a String.replace() call on any HTML files served, without affecting other files.
A way to use EJS or another templating engine that lets me put something like "<include /templates/header>" into my HTML pages, and then when the file is served to the client, that line is replaced with the content of /templates/header.
Anything else that lets me do what I want in a reasonable way.

Get
Ṁ1,000
to start trading!

🏅 Top traders

#NameTotal profit
1Ṁ43
2Ṁ5
© Manifold Markets, Inc.TermsPrivacy