You can improve it by separating design into separate files (say header, footer, etc). Doing things from shell is not very much different from doing things from browser.
You can use very simple template language with sed or awk (just replace keywords with actual values for example).
Alternative: just rewrite it to command some template engine (no, I do not have any recommendations).
Edit: Positive side is that it is a single file, so I can see your point. But as the projects as multiple files anyway, it is perhaps still worth a consideration.