I am going to write a big website, it has hundreds of HTML pages. There are some parts of the file using the same HTML code, such as the banner, the bottom disclaimer, etc.
I want to update the common parts of the HTML in a batch when that parts are modified, I am seeking a way to efficiently do that.
Currently my solution is surround the tempates with HTML comments, and use Linux script(sed mainly) to update it when necessary. Like:
<!-- Template1 -->
<!-- Template1-end -->
Any better way?
Template Toolkit is your friend. If you are building using a shell script that spits out static files (and it sounds like you are), then you’ll want the ttree utility. You’ll probably find the tutorial useful and want to make use of the WRAPPER directive (which lets you have a complete page with “Insert content here” sections rather then having to stick “Include header”, “Include nav”, “Include footer” in every content page).
Going with TT gives you the flexibility to move to server side scripting in the future with a minimum of effort (so long as you are happy using Perl for the server side programming) as Template-Toolkit has Perl modules as well as ttree.