Chapter 2: Building a Templating System
In This Chapter
Understanding how templates simplify global changes
Building a template
This chapter looks at template systems and how they can reduce the amount of work that you need to do to make a website. We tell you how to build a template that’s both simple and powerful for many uses, style the page, and then extend the template to other pages on the site.
After working your way through this chapter, you could further extend the templating system to add more specialized pages or even further abstract it so that you can add CSS and JavaScript elements on the fly, rather than through individual external files.
Understanding Template Systems
When you make a website, you frequently use the same layout for the entire site. You have a top portion, maybe with a menu; a main content area; and a bottom part, maybe with links or a copyright notice. Each and every page needs the same CSS and HTML to create this integrated look and feel throughout the website.
When your website has only a couple pages, it’s probably fine to keep the HTML and CSS separate. If you need to make a change, say to add a menu item or change the copyright year, you can just edit each file. But imagine if your website has dozens or even hundreds of pages. Now changing ...