Customization of SharePoint sites through the UI is a
labor of love for some. For others, it’s simply work. Regardless of how
or why it is done, customization is something that end users can spend
countless hours doing in SharePoint. Customization activities include
altering the look and feel of a site, creating custom views for lists,
modifying the usage and settings for Web parts, and much more.
Note
In the context of this section, the term customization
is being used to describe changes that end users make to a SharePoint
site or its constituent parts through the browser-based UI or SharePoint
Designer. Customization does not refer to farm-deployed solutions,
sandboxed solutions, or any other form of code-based solution unless
explicitly indicated.
One way that end users can
capture and save such customizations within the SharePoint environment
is through the use of templates. For example, a template can be used to
bundle up the changes that are made to a list, modifications that have
been made to the columns it contains, views that have been added or
changed, and more. In addition to capturing these structural changes,
templates can be used to save data and content. In the case of the list
example, end users have the option of choosing to include the data that
is in a list at the same time the structural information is captured in a
template.
Once you have created a
template, it is available for re-use within the site collection it was
created within. End users can also download templates that have been
created for use in other site collections and SharePoint environments;
this use is most attractive to the average end user from a content
protection and disaster recovery perspective.
With the removal of personal
Web package export and backup creation capabilities from Share-Point
Designer 2010, templates remain one of the few mechanisms that end users
have at their disposal to package and move content out of SharePoint
sites in a structured form. Templates that can be created, exported, and
imported by users come in two varieties: list templates and site
templates.
List Templates
The first type of template
that end users can generate through the SharePoint browser-based UI is a
list template. The overwhelming majority of data and content within
SharePoint is stored in list form, so the ability to create a reusable
template from virtually any list in SharePoint is quite powerful.
As described earlier, a
list template allows end users to capture the structure and
customizations that are tied to a specific list or document library in
SharePoint. At the same time, end users can choose to include all the
list item content that the list or document library possesses at the
time of template creation.
The process of list template creation can be distilled into the following sequence of steps:
Customize a list or document library and optionally load it with content in the form of list items.
Select the Save ... as Template link from within the settings page for the list or document library in the browser-based UI.
On
the Save As Template Web page that is displayed, provide a file name,
template name, and description. Optionally, you can specify that list or
document library content be included with the template.
SharePoint
adds a new list item to the List Template Gallery for the site
collection containing the list or document library that was used to
generate the template.
Templates that are present in
the List Template Gallery as a result of the steps just described are
available for end users to select when they go to create a new list or
document library in the site collection. You can also download templates
in the List Template Gallery with the Save Target As option that is
available when you right-click a template name, as shown in Figure 1.
Templates that you
download can be imported into another site collection using the Upload
Document option on the ribbon of the List Template Gallery. Once you
have uploaded a list template to the List Template Gallery, it becomes
available for use in the creation of new lists in the destination site
collection just as it had been in the source site collection.
Site Templates
The
second type of template that can be generated from within the
browser-based UI is a site template. Whereas you use a list template to
capture the structure and content of a single list or document library,
you use a site template to capture the equivalent information for an
entire SharePoint site or subsite. The template process doesn’t
recursively capture subsites below the site targeted, though—only the
site itself.
In most regards, the process
of creating and using a site template is the same as the process that
was described for list templates. There are a few differences worth
noting, though.
The link to create a template is located under the Site Actions menu of the Site Settings page.
Templates
that you create are stored (somewhat nonintuitively) in the Solutions
Gallery for the site collection. You can download existing templates
from the Solutions Gallery, and you can upload templates that you want
to import to the Solutions Gallery.
Templates
in the Solutions Gallery are available for selection when end users
want to create a new site or subsite, such as through the New Site
options on the Site Actions menu.
SharePoint Designer and Templates
If you have used
SharePoint Designer 2010 and examined the application’s ribbon while
working with either a site or list, you have probably seen the Save As
Template button that is shown circled in Figure 2.
As was the case with
SharePoint Designer 2007, this button doesn’t launch
application-specific functionality within SharePoint Designer 2010.
Instead, it opens a browser window and directs the browser to the savetmpl.aspx application page in SharePoint’s _layouts virtual directory. From the savetmpl.aspx
page, you have the ability to create both site and list templates.
That’s the extent to which SharePoint Designer assists with site and
list template creation.
Interestingly enough, the savetmpl.aspx
page is the same page from which site and list templates are created
when using the browser-based UI for these tasks. In reality, SharePoint
Designer doesn’t really provide template creation capabilities—it simply
hands control over to a SharePoint application page and removes itself
from the operation.
An Administrative Perspective on Templates
Much
like versioning, the creation and use of both site and list templates
are tasks that end users can carry out on their own without having to
trouble you, the administrator. There are a few template-related points
of note, though, that you should be aware of.
Templates and Publishing Sites
When your users begin
working with templates, they may report that the links to create site
and list templates don’t always appear within the Site Settings and List
Settings pages. In addition, your users may report that the Template
Creation button on the ribbon in SharePoint Designer is sometimes grayed
out.
In most cases, this behavior is
by design and is tied to site collections that are based on publishing
templates such as the Publishing Portal and Enterprise Wiki. Due to some
of the unique relationships that exist within publishing sites, such as
the relationship between layout pages and content types, Microsoft does
not support the creation of templates from publishing sites and lists
within them. This lack of support is reinforced through the disablement
of template creation links in publishing sites.
Strictly speaking, it is still possible to create templates for publishing sites and lists by navigating directly to the savetmpl.aspx application page within the _layouts virtual directory of a publishing site, but it is obviously not recommended and supported for reasons already mentioned.
Setting Limits on Templates That Can Be Generated
Another common barrier that
users encounter with templates is the maximum size of the template they
can create. By default, the maximum size of a list or site template that
can be created is roughly 50MB in SharePoint 2010. Attempts to create a
template that is larger than 50MB are met with an error dialog box
similar to the one shown in Figure 3.
Storage of 50MB is typically
ample for templates that include structural elements without site
content and list items, but templates that include content from large
lists and sites can easily exceed this limit.
As an administrator, you
have the ability to increase or decrease the maximum size limit for list
and site templates that end users can generate from within SharePoint
sites. However, before making changes to the limit, there are a few
points worth mentioning:
Any changes that you make to the maximum size limit apply to all site collections within the SharePoint farm.
The
creation of large templates can place a significant load on the Web
server where the template is generated. This can adversely affect the
performance of your SharePoint environment.
Attempts
to create templates that are too large may lead to erratic behavior and
browser timeouts. The actual point at which undesirable behavior
manifests varies from environment to environment, so you should
understand how your farm behaves under load before setting the maximum
template creation size to too large of a value.
If changing the maximum
template creation size is something you conclude that you want to do,
there are two ways to accomplish it. The recommended approach involves a
few simple lines of PowerShell script to change the MaxTemplateDocumentSize property value on the content Web service for the SharePoint farm:
$cws = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$cws.MaxTemplateDocumentSize = <new maximum>
$cws.Update()
Alternatively, you can fall back to using STSADM.exe to make the same change:
STSADM -o setproperty -pn max-template-document-size -pv <new maximum>
In both the PowerShell and STSADM.exe examples, the <new maximum> value specified is the new template size creation limit in bytes. A value of 150000000,
for example, changes the maximum template creation size to
approximately 150,000,000 bytes, or 150MB, for all site collections
within the farm.
Templates and Security
As an administrator,
there is an additional point you must consider when determining how
templates are or are not going to be used within your organization:
security. Although the creation of templates that contain only
structural information don’t pose much of a concern, a user’s ability to
include list item content within a template does. If sites or lists
contain sensitive content, that content can be written out in a template
by default. Once the content is written to a template
and subsequently downloaded, anyone who can access the downloaded
template has access to a copy of the content data that was exported.
There are a couple of simple options available to you if you want to restrict how templates can be created and downloaded.
You can tune and
reduce the maximum size of a template that can be created. Because list
item content can quickly “bulk-up” a list, some experimentation may
allow you to set a maximum template creation size that is adequate to
allow the creation of structural templates without permitting the
creation of templates that include list item content.
By
controlling the permissions on the List Template Gallery and Solution
Gallery for a site collection, you can control who can create templates,
who can access templates, whether or not templates can be deleted, and
more.