What shell are you using here? In bash, I would run something like:
for f in ./posts/*.md; do
dst=site/${f%.md}.html
cat head.html >$dst
markdown $f >>$dst
cat footer.html >>$dst
done