Template tips
Dreamweaver templates can help you create web pages with a consistent design and layout. Templates also make it easy to update and maintain your site. Simply revise the templates and automatically update your site's pages based on the templates. To get the most out of using templates, you'll find tips for the following topics.You'll also find a list of other TechNotes featuring the use of templates in Dreamweaver in the Additional information section below.
| |
Using the Templates folder |
| |
Identifying the path to the template file |
| |
Creating paths to other pages (or page elements) in templates |
Using the Templates folder
Dreamweaver houses template (DWT) files in a folder named"Templates." Located at the root level of the local root folder, the Templates folder should only be used to store template files:
| |
Don't move your template files outside of the Templates folder. |
| |
Don't put any files other than template files in the Templates folder. Separating the template files in this manner will help you avoid confusion. Also, when you upload your site files, you will not need to upload the Templates folder to the server. |
Identifying the path to the template file
Every document based on a template contains the path to the correct DWT file in the Templates folder. That path is written within comment tags;Dreamweaver uses this path to the template within the Templates folder when it updates the pages based on that template. When you apply a template to an existing page or create a new document from a template, Dreamweaver codes the path to the template as follows:
<!-- #BeginTemplate "/Templates/templatename.dwt" -->
Dreamweaver uses this path information in the source code to identify which pages belong to which template.
Creating paths to other pages (or page elements) in templates
When you link to other pages or insert elements (such as images) on your page, Dreamweaver creates a path in the HTML source code of your document so that a browser displaying your page can find the appropriate files. For an in-depth explanation of the three kinds of paths (and how to interpret them), please see Different path types (TechNote 15595).
Editable versus non-editable regions of the template
Paths can be in either editable or non-editable (locked) regions of a template. A path placed in an editable region of a template will not change when a page is created based on the template.
When Dreamweaver writes paths in non-editable regions of templates, however, the links behave differently. The effect of using the different kinds of paths in non-editable regions of templates is discussed below:
Paths in the non-editable regions of templates:
| |
Document-relative paths in templates |
| If you allow Dreamweaver to create the document-relative path in the template (by clicking the Browse for File icon on the Property inspector, for instance), the path to the page or element will be;in the template itself;relative to the template. When you create a page based on the template, Dreamweaver will alter the path in the new page to reflect the page's new location. In other words, Dreamweaver is smart enough to know that your page based on the template is in a folder different than the one holding the template and so the document-relative path in the new page will reflect this change. Note:If you wish to type your document-relative path yourself, remember to make the path relative to the template's location and not to where you think the future page based on the template will be. If you type a document-relative path that points to a location outside of the Templates folder, the link will ultimately not work in the browser or the element will not display in either Dreamweaver or the browser. For an illuminating pictorial explanation of how Dreamweaver adjusts document-relative paths in a pages based on a template, seeUnderstanding paths in Dreamweaver templates (TechNote 13842). |
|
| |
Site root-relative paths in templates |
| Dreamweaver does not adjust site root-relative paths in pages based on a template, because the adjustment is not necessary. Site root-relative paths work from any location within the same site. Important note: Use document-relative paths in templates, unless you plan on using site root-relative paths site-wide.An extremely rare error in Dreamweaver may rewrite your existing paths as site root-relative throughout your site if even one site root-relative path is found within your template. This change will not affect the functionality of your site, but such a change would understandably be surprising to some users. |
|
| |
Absolute paths in templates |
| Dreamweaver does not adjust an absolute path in a template when a page is created based on the template. Absolute paths work without regard to the source file's location. |
Additional information
For more details about templates and paths, please see the following TechNotes:
| Document title changes after applying a template (TechNote 15544) |
| Templates folder appears in path (TechNote 15343) |
| Using CSS styles with templates (TechNote 15243) |
| How to link HTML files in templates (TechNote 14048) |
| Understanding editable and non-editable regions in templates (TechNote 14804) |
| Important information to consider when using templates (TechNote 14627) |
| Adding content to pages from a Template in Dreamweaver 4(TechNote 14908) |
| Adding behaviors to templates and to documents created from templates (TechNote 14797) |
| Using Library items to add behaviors to documents created from templates (TechNote 14852) |
| How to incorporate image maps in templates (TechNote 13880) |
| Understanding paths in Dreamweaver templates (TechNote 13842) |
This content requires Flash
To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.
Download the free Flash Player now!
