Reusing Content with Templates and Libraries > Creating templates |
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.
If you want to store additional information about a template, such as who created it or when it was last changed or why you made certain layout decisions, you can create a Design Notes file for the template. The documents based on the template do not inherit the template's Design Notes. (For more information, see About Design Notes.)
Most template-related operations are available only when the Design view is active. If a template-related command is dimmed when the Code view is active, click in the Design view.
To save an existing document as a template:
1 | Choose File > Open and select a document. |
2 | When the document opens, choose File > Save as Template. |
Note: If the document is based on a template, you must detach it from that template before you can save the document as a template in its own right. | |
3 | 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. |
4 | Click Save. |
The template file is saved in the site's Templates folder, with a .dwt file extension. | |
To create a new, blank template:
1 | Choose Window > Templates. |
The Assets panel appears, with the Templates category selected. | |
2 | In the Assets panel, click the New Template button at the bottom of the Assets panel.
|
A new, untitled template is added to the list of templates in the panel. | |
3 | While the template is still selected, enter a name for the template. |
To edit the template file that a document is based on:
Choose Modify > Templates > Open Attached Template.
To edit a template file:
1 | Choose Window > Templates. |
The Assets panel appears, open to the Templates category. The bottom pane of the Assets panel lists all of the available templates for your site. The top pane displays a preview of the selected template. | |
2 | In the Assets panel, do one of the following: |
Double-click the name of the template. | |
Click the Edit Template button at the bottom of the Assets panel.
|
|
3 | Edit the template in the Document window. Create editable regions in the template as desired (see Defining a template's editable regions). |
4 | Save the edited template by choosing File > Save. |
Note: If you haven't defined any editable regions, you'll be warned at this point that your template contains no editable regions. You can save the template anyway, and you can modify the template file even if it doesn't contain editable regions, but you won't be able to modify documents based on the template until you've created an editable region in the template. | |
To rename a template in the Assets panel:
1 | Click the name of the template once to select it. |
2 | After a brief pause, click again. |
3 | When the name becomes editable, enter a new name. |
Note: This method of renaming works the same way that renaming a file in Windows Explorer (Windows) or the Finder (Macintosh) does. As with Windows Explorer and the Finder, be sure to pause briefly between clicks. Do not double-click the name; that opens the template for editing. | |
4 | Click elsewhere, or press Enter (Windows) or Return (Macintosh). |
5 | Dreamweaver asks if you want to update documents that are based on this template. |
To update all documents in the site that are based on this template, click Update. | |
To refrain from updating any documents that are based on this template, click Don't Update. A document that you choose not to update is still based on the template (not detached); to update such a document later, open the template and choose Modify > Templates > Update. | |
To delete a template file:
1 | Select the template in the Assets panel. |
2 | Click the Delete button and confirm that you want to delete the template. (Be careful; if you delete a template file, you can't retrieve it.) |
The template file is deleted from your site. Documents that were based on this template are not detached from the template; they retain the structure and editable regions that the template file had before it was deleted. To turn such a document into a normal HTML file without editable or locked regions, use Modify > Templates > Detach from Template. For more information, see Detaching a document from a template. | |