Problem solved, in a very UNIXy way!
for page in $pages;
$(which comrak) $page.md > $page.temp.html
cat header.template $page.temp.html footer.template > $page.html
omg I'd totally forgotten about `printf`! If nothing else, trying to get this tilde server off the ground has helped _me_ get better at doing things the UNIX way.
This is a server created by Jahziel Villasana (aka hapax). He's not sure what he's going to use it for yet...