In the previous recipes in this chapter, each page contained the entire Visualforce markup needed to display its content. This leads to repetition of common markup, to display headers and footers for example. In the event that the header or footer content needs to be changed, every page on a site needs to be updated with the new markup.
Visualforce provides a solution to this issue—templates. These allow the common elements of a site to be added to a template that is used as the starting point for rendering any page. The page then injects its specific content into the template at appropriate points.
In this recipe we will create a template version of the SiteItem Visualforce page from the Retrieving content from Salesforce recipe, where the template provides the header and footer markup. We will then make this page available publicly available via an unauthenticated Force.com site.