Retired Documentation:  You are using the documentation for version 1.7.3 which was retired in 2013. Go here for the latest version documentation or check here for your available upgrades to the latest version.

Saving Templates to Text Files

ExpressionEngine includes a feature that will allow you to save your Template data as a regular "flat text" file on your server. This feature is useful for people who prefer to use a program such as Dreamweaver, GoLive, BBEdit, etc. to edit and make changes to their Templates (and FTP the changes to the server).

Enabling Saving Templates as Files

In order to use this feature you must first turn it on and set it up.

Prepare a directory

You must prepare a directory/folder on your server that will contain the saved Template files. Most people will create their directory inside the normal system/ directory. For example, if you want your directory named "template_files" then you would create a system/template_files/ directory on your server.

You must then make the directory writable by setting the permissions on the directory to 777 so that ExpressionEngine will be allowed to save the files as well as recreate your Template_Group/Template structure.

Set Control Panel Preferences

Once your directory is created and permissions are set correctly, you can log into your Control Panel. Go to Templates > Global Template Preferences. There are two preferences you need to set.

  1. Allow templates to be saved as files? Set this to "Yes".
  2. Basepath to Template File Directory: You must place the server path to the directory you created above in this preference.

It is important that you use the server path for the preference and not a URL. A server path often looks similar to /home/usr/ Server paths will vary from server to server, so you should contact your Host or server admin if you are unsure of what your setting should be.

Running your Site with Flat File Templates

Using the Feature

Once you have set things up as indicated above, you will then see a new checkbox become available at the bottom of your Template editing page.  When you submit your template with the box checked, the Template will be saved as a file (in addition to updating the database).  It will also tell ExpressionEngine to use the file version of the Template instead of the database whenever your pages are viewed.  Because ExpressionEngine is using the file version, you can then use an external program such as Dreamweaver, GoLive, BBEdit, etc. to make changes to the file without using the Control Panel interface.

Note:  If you have been making changes to your template files via FTP, and you then go back to the Template editing page, ExpressionEngine will load the file version into the form.  However, unless you click "save", the database will still contain the last version you saved via the Control Panel.

Saved Template Files

When you save your Template to a file, the file is saved inside the directory that you created above. Files are saved according to your Template Group/Template structure. That means if you save the "comments" Template inside the "weblog" Template Group, ExpressionEngine will create a saved Template file similar to this: system/template_files/weblog/comments.php.

Saved Templates and the Multiple Site Manager

Sites under the Multiple Site Manager have their own preferences for saving templates as text files. As such, when setting up a new Site under the Multiple Site Manager, you must set up a new location for saving those templates.

When importing or duplicating to a new Site in the Multiple Site Manager, if you wish to use existing templates which are saved as text files, then the template directory must be manually copied to the directory for the new Site.

Top of Page