Insert server-side includes, Insert a server-side include – Adobe Dreamweaver CC 2015 User Manual
Page 413

406
Coding
Last updated 6/3/2015
With Dreamweaver you can preview documents just as they’ll appear after they’re on the server, both in the Design view
and when you use the Preview in Browser feature. To do so, however, you must make sure you are previewing the file
that contains the include as a temporary file. (Select Edit > Preferences, select the Preview in Browser category, and
make sure the Preview using temporary file option is selected.)
Note: If you are using a testing server, such as Apache or Microsoft IIS, to preview your files on your local drive, you do not
need to preview the file as a temporary file because the server does the processing for you.
Placing a server-side include in a document inserts a reference to an external file; it doesn’t insert the contents of the
specified file in the current document. The contents of the specified file should only contain the content that you want
to include. That is, the include file should not contain any head tags, body tags, or html tags (meaning the tag—
formatting HTML tags, such as p tags, div tags, and so on, are fine). If it does, these tags will conflict with the tags in
the original document, and Dreamweaver won’t display the page properly.
You cannot edit the included file directly in a document. To edit the contents of a server-side include, you must directly
edit the file that you’re including. Any changes to the external file are automatically reflected in every document that
includes it.
There are two types of server-side includes: Virtual and File. Dreamweaver inserts File type includes by default, but you
can use the Property inspector to select the one that is appropriate for the type of web server you use:
• If your server is an Apache web server, select Virtual. In Apache, Virtual works in all cases, while File works only in
some cases.
• If your server is a Microsoft Internet Information Server (IIS), select File. (Virtual works with IIS only in certain
circumstances.)
Note: Unfortunately, IIS won’t let you include a file in a folder above the current folder in the folder hierarchy, unless special
software has been installed on the server. If you must include a file from a folder higher in the folder hierarchy on an IIS
server, ask your system administrator if the necessary software is installed.
• For other kinds of servers, or if you don’t know what kind of server you’re using, ask your system administrator
which option to use.
Some servers are configured to examine all files to see if they contain server-side includes; other servers are
configured to examine only files with a particular file extension, such as .shtml, .shtm, or .inc. If a server-side include
isn’t working for you, ask your system administrator if you need to use a special extension in the name of the file
that uses the include. (For example, if the file is named canoe.html, you may have to rename it to canoe.shtml.) If
you want your files to retain .html or .htm extensions, ask your system administrator to configure the server to
examine all files (not just files with a certain extension) for server-side includes. Parsing a file for server-side
includes takes a little extra time, so pages that the server parses are served a little more slowly than other pages;
therefore, some system administrators won’t provide the option of parsing all files.
Insert server-side includes
You can use Dreamweaver to insert server-side includes in your page.
Insert a server-side include
1
Select Insert > Server-Side Include.
2
In the dialog box that appears, browse to and select a file.
By default, a File type of include is inserted.