Re:“Make” as a Static Site Generator
by envsubst on Sunday September 10, 2023 @09:56AM
(#37455787)
Instead of `m4` or `sed` find and replace, the author should try `envsubst`. It's a program that replaces bash style variable references (for example `$TITLE`) with their value in the environment.
[ Parent
| on HN ]
The problem is that the $SOMETHING syntax is just too common if your site is a technical one, and you'll end up substituting too much.
You can specify which variable names are valid, reducing the likelihood of a collision.
I agree that `envsubst` is a good choice for this. Unfortunately, it is not part of posix, so you can't rely on it being present everywhere. But as part of gettext, it is still very common.