You can create a system of scripts and templates to generate Web pages that share a look and feel. Starting from the basics, here's a description of how I created a script and template system for generating web pages:
- First, I created an HTML template for the overall look and
feel for a typical page of my web.
In place of titles and strings of information which may
change from page to page, include parameters of the
stringis some identifier such as
For example, I created this template for personal files on my web site. Notice that it has parameters:
- I broke up this HTML template into two files at the
XX-CONTENTline, leaving this line out of both files: name one as head file and the other as foot file.
- I made a script to sandwich a file of content between
this head and foot file.
For example, here's the
makejohn1.0Unix script to sandwich a contents file between the header and footer file.
I create a directories "bin" to hold my scripts, "src" to hold my header, footer, and contents files, and "gen" to hold the generated files. For every file in my directory, I don't store header or footer information, just the content in the
srcdirectory. For example, I place my
hobbies.htmlfile, without header or footer information in
I ran the
makejohn1.0script with the content file
hobbies.htmlas its parameter:
$ makejohn1.0 hobbies.html
makejohn on hobbies.html
generated in ../gen/hobbies.html
I've improved my implementation system one order of abstraction over a template method because I'm no longer tied to a fixed header and footer for each file. I can always switch headers and footers and regenerate the file. I could move the generated file from
../gento the Web server space, or I could just generate the file with the GENLOC variable set in my script to the appropriate place.
XX-information is still in the generated file. I could replace this by hand in each generated file, but then this would be work that I'd have to repeat if I change my head or footer styles later on.
- The script
XX-information. It takes three arguments: the filename, the title, and the annotation and generates the HTML file, replacing the
$ makejohn1.1 hobbies.html "My Hobbies" "These are things I do when I have some spare time..."
makejohn on hobbies.html My Hobbies These are things I do when I have some spare time...
generated in ../gen/hobbies.html
The result is that I have enforced a look and feel and have parameterized the variations from file to file. I create a
makejohnwebscript to contain the call to the
makejohn1.1script so that I can add more lines to
makejohwebas I develop more content files, such as:
makejohn1.1 resume.html "Resume" "Education and work experience"
makejohn1.1 faq.html "FAQ" "These are questions (with answers) that I frequently receive by email..."
- I can create another level of abstraction by parameterizing the style of the
header and footer.
I create a makestyle script which has
has an additional arguments for style.
This script requires that I have style files prepared.
For example, I create
bookfoot.html, and a "bare" contents file,
src/hcu.htmlThen I can generate a "book style file":
$ makestyle hcu.html book "HTML and CGI Unleashed" "This book helps you in all stages of Web development"
makestyle on hcu.html book HTML and CGI Unleashed This book helps you in all stages of Web development
generated in ../gen/hcu.html
I can collect similar book style generation lines in a
This technique can become more sophisticated and powerful as you make your scripts more elaborate and parameterize more elements of your web's style.
With some more creative changes, I could parameterize the XX- strings I include in the header and footer files. I could have "cascading styles" where a particular style borrows elements from several other styles--perhaps the head from one style, the foot from another.
Eventually, style sheets in HTML may be able to implement many of the look and feel decisions that I'm currently placing in the header and footer files and scripts. If so, I can modify my scripts to generate these style sheets and put that style information in HTML elements in the head and foot file. In fact, I could use different generation techniques to generate a text-only version of my web, a frames version, or a version with only particular HTML elements--it is simply a matter of changing my scripts or the head and foot files.
See the HTML Toolbox for software that can help you build Web pages.