Reusing Content with Templates and Libraries > Templates and libraries overview

 

Templates and libraries overview

The Assets panel (see Asset management overview) provides access to all of the assets in your site. Macromedia Dreamweaver provides two special "linked" categories of assets: templates and libraries. A page that uses a linked asset is automatically updated when you change the linked asset.

Dreamweaver templates and libraries can help you create Web pages with a consistent design. Using templates and libraries also makes it easier to maintain your Web site, since you can redesign your site and change hundreds of pages in seconds.

A template is a document you can use to create multiple pages that share the same layout. When you create a template, you can indicate which elements of a page should remain constant (noneditable, or locked) in documents based on that template, and which elements can be changed.

For example, if you're publishing an online magazine, the masthead and overall layout probably won't change from one issue to the next, or even from one story in the magazine to the next, but the title and content of each story will be different. A designer can create the layout of a story page for the magazine, with placeholder text where the story's title and contents will be (and with those regions marked as editable); the designer can then save that layout as a template. The person putting together a new issue of the magazine creates a new page based on the template, and replaces the placeholder text with the actual title and text of the new story.

You can modify a template even after you've created documents based on it. When you modify a template, the locked (noneditable) regions in documents that are based on the template are updated to match the changes to the template.

Note: If you open a template file, you can edit everything in that file, whether it's marked as editable or locked. If you open a document that is based on a template file, you can edit only the regions that are marked as editable. So the terms editable and locked refer to whether a region is editable in a document based on a template, not to whether the region is editable in the template file itself.

Templates are best for situations in which you want a set of pages to have an identical layout—where you want to design the complete final layout for a set of pages first, and then add content later. If you simply want your pages to have the same headers and footers, with different layouts in between, use library items to store the headers and footers. (Library items are stored page elements that you can reuse in multiple pages; as with templates, you can update all the pages that use a library item whenever you change the item's contents. For more information, see Creating, managing, and editing library items.) It's important to note that for pages created with templates, you can't convert tables to layers or layers to tables.

Note: Using a template may limit your later changes to design and layout. If you intend to make major layout changes to your pages later, you may want to use library items instead of templates.

Templates are particularly useful in a collaborative environment in which a designer controls the page layouts, and other people add content to the pages but aren't allowed to change the layout.

Dreamweaver also provides other kinds of reusable content: server-side includes and library items. You might use these elements for content that appears on every page of the site (such as a header or footer) or for content that appears on only a few pages but must be updated frequently (such as news headlines or sales discounts). These approaches are appropriate for different kinds of sites:

Server-side includes can be used only for sites that are viewed from a server, not for sites that are viewed on a local system without a server. They can be seen only on servers that are configured to process server-side includes. (Ask your webmaster or system administrator whether your Web server supports server-side includes.) See Using server-side includes.
Library items can be used on sites that are viewed locally as well as those that reside on a server. On sites that are viewed locally, without a server, you must use library items rather than server-side includes. See Creating, managing, and editing library items.