in reply to templates vs here docs

I would recommend here docs only for small sites with low complexity. An aesthetic problem of here docs is that it's not possible to use conditional blocks or loops without in the here doc, rather, you have to split the here doc into multiple parts.

My recommendation for a templating system is Template-Toolkit. It's widely in use, has many (useful) features, is extensible and it can be used for all kind of templating problems, not just html templating.