Templates are used to create documents that have a common structure and appearance. Templates are useful when you want to make sure that all of the pages in a site share certain characteristics. You can design a template to have graphics and navigational links that you want to be shared by all of the pages in your site. When changes are made to the template, they are automatically changed on all of the pages that were created from that template. The template also contains spaces for content that can be edited on the individual pages.
Getting Started
- In order to use templates in Dreamweaver, you must set up a site. A site is an entire group of web pages that logically belong together. This logical group of pages is then physically placed in a folder on the webserver. All of the pages in the site and any graphics that are used must be in the same physical folder. Note: It is much easier to decide to use templates before you start creating your pages. If you already have web pages created in different folders on the webserver, they will have to be moved into the physical folder defined by the site.
- To define a new site, choose Site > Define Sites. A dialog box will appear. Choose New.
- In the Site Definition box, type in a descriptive site name.
- Next, find the physical location of where your site and all of your files will reside. In most cases, this folder will be the place you normally would store your web pages. To find the Local Root Folder, click on the icon of a folder next to the box. A window will appear allowing you to find your web space. This may be on your K: drive if you are a student creating personal pages. Or, it may be on the the W: drive if you are a designing club web pages or a faculty member. Find the drive you need under the pull-down menu and then change to the appropriate folder. Click the Select Button.
- Type in the address (URL) of your web site in the HTTP Address box.
- You have now defined a site that your template and all corresponding pages will belong to. All of your pages, templates, and graphics must be physically in that same folder location.
Creating a Template
You can create a template from an existing HTML document and then modify it to suit your needs, or you can create a template from scratch, starting with a blank HTML document.
Dreamweaver saves templates with the file extension .dwt in a folder named Templates in your site's local root folder. If the Templates folder does not already exist, Dreamweaver creates it when you save a new template.
Note: Do not move your templates out of the Templates folder, or put any nontemplate files in the Templates folder. Also, do not move the Templates folder out of your local root folder. Doing so causes errors in paths in the templates.
To save a document as a template. :
- Choose File > Open and select a document. Or, you can choose File > New to start with a blank document that will become your template.
- When the document opens, choose File > Save as Template.
- In the dialog box that appears, select a site from the pop-up menu, then enter a name for the template in the Save As box.
- Click Save. The template file is saved in the site's Templates folder, with a .dwt file extension.
Defining a template's editable regions
In a template, editable regions are the parts of the page that can be changed in files based on the templatefor example, the text of an article in a newsletter would appear in an editable region, so that every article could contain different text. Locked (noneditable) regions are the parts of the page layout that remain constant from one page to another.
All regions in a new template are locked when you create the template, so to make the template useful, you must make some regions editable (unlock them).
While you are editing the template file itself, you can make changes to both editable and locked regions. In a document based on the template, however, you can make changes only to the editable regions of the document; the locked regions of the document can't be modified.
To define existing template content as an editable region:
- In the template file, select the text or content you want to change to an editable region.
- Choose Modify > Templates > New Editable Region.
- In the New Editable Region dialog box, enter a unique name for the region. (You cannot use the same name for more than one editable region in a particular template.)
Creating a New Document Based on a Template
- Choose File > New from Template.
- In the dialog box that appears, choose a template.
- If you don't want your new document to update when the template changes, deselect Update Page When Template Changes.
- Click Select.
Applying a Template to an Existing Dreamweaver Document
- Open the document.
- Click in the Document window's Design view, then choose Modify > Templates > Apply
Template to Page.- Choose a template from the list and click Select.
Changing a Template and Applying Changes to Other Documents
- Open the template.
- Make desired changes to the template.
- Choose File > Save.
- A prompt will appear to update all of the documents that share the template. Click Yes.
- An Update Pages dialog box will appear. Click Done