Maintain a static website using an HTML preprocessor

I have a static website with many similar pages. The site is very simple, basically just information for me and some other people. Basically I would like to spend as little time as possible keeping it.

Certain pieces appear on each page and change every so often (the header and footer, for example, but other similar pieces are also repeated). I currently copy and paste them on every page they appear on, but obviously this is prone to errors and it is very frustrating for me to maintain.

My initial idea was for JS to load similar parts of the site, but this seems like an exaggeration for such a simple site, and makes reading the site offline (in a text editor or terminal, for example) is a giant pain because one has to jump between different files.

My second thought was to use the C preprocessor to generate the HTML files, for example, making #include "repeat_section.html" and a few macros to build the HTML from pieces. This seems to work fine, (the generated HTML works, and it's nice and readable in a text editor), but it feels like a hackey. Is there an "adequate" tool to do this? Has anyone tried my way and has a problem?