1. Look at the huge list of open-source static site generators (literally hundreds![1])
2. Try some out, and fail to find one that works exactly right.
3. Start writing a new one that fits better.
4. Gradually extend it and make it more general.
5. Get excited about how useful it is, and publish it as an open-source project so others can use it, adding it to the already enormous list.
6. Someone else starts at step 1.
[1]: https://www.staticgen.com/
I've taken to just building a new one one to meet whatever my immediate need is, and developing a sort of mental toolkit of techniques rather than trying to smush an existing program into the particular requirements of a specific project. You can get surprisingly far with just a handful of lines of code.