Wednesday, November 11, 2009

Site Definitions vs. Site Templates

SharePoint Customization: Site Definitions vs. Site Templates

One of the biggest challenges in customizing your SharePoint site is deciding whether the customization must happen at the site definition or site template level. Learn the strengths and weaknesses of each approach so you can make the right decision for your environment.

SharePoint technologies offer two key ways to create a "rubber stamp" from which you can create sites. The site definition approach is a hard-core method that involves editing ASPX pages, modifying XML, and generally looking behind the covers. The site template approach is easier, and just requires the use of the Web interface and occasionally Microsoft FrontPage. However, the site template approach doesn't support every kind of change and requires you to be particularly careful not to unghost pages in the site. Site definitions open the entire array of options for change to you, but they're substantially more difficult to create. The choice between these two approaches largely depends on your situation.

In this article, I walk you through the strengths and weaknesses of each approach and expose the criteria you can use to make an educated decision about which one is right for you.

Site templates

Site templates in their most basic form are easy to create. You simply configure a site the way you want it and save that site to a template (STP) file from the site administration pages (Site Settings > Site Administration > Save site as template). The sheer ease of creating a site template makes it ideal for low-effort customization. If you want a few more lists than the standard site definition creates, simply create a site template.

Site templates offer these advantages:

No server touch -- Site templates don't require access to the server. Site definitions by contrast require file system access to the SharePoint server, and the ability to reboot Microsoft Internet Information Services (IIS) for your development server.

Easy to create -- Site templates are easy to create from the site administration menus. You can customize the site using the Web user interface or Microsoft FrontPage.

Single file deployment -- Because everything you need is in the single STP file, you don't have to worry about putting the files in the correct directories or accidentally creating a conflict. Of course, the site definition on which the site template is based must be on the server.

Changes to the template after sites have been created -- Because the template is just a rubber stamp applied when you create the site and there is no further connectivity with the template, you can change the template at will. However, your changes won't be reflected in the site.

No need to coordinate with other groups -- Because there aren't any internally significant identifiers in the template file, you don't have to coordinate globally unique IDs with other groups as you do with site definitions.

There are many good reasons to customize your SharePoint site with site templates. However, there are also some challenges. The primary challenges with using site templates as your customization strategy are uhghosting and list definitions.

Unghosting

Windows SharePoint Services (WSS) is able to maintain a high level of performance because it uses pointers in the database to files located on the Web servers' file system. Pointers let you virtually include a single file on the file system in every site, thereby increasing performance. Almost anything you do to a site in FrontPage that requires you to save so the change takes effect causes WSS to make a copy of the original page and store it in the database. This process makes upgrades much more difficult and reduces performance by 15-20 percent. There are many ways around this scenario, but anytime the layout of the page has to change and you're using a site template, you'll be unghosting the page and dealing with the consequences. Unghosted pages, in addition to being slower, can't contain any server-side code and can't load controls you haven't listed in the SafeControls section of the web.config file.

List definitions

List definitions, which are part of the site definition, drive the list content, including the default fields, views, and forms. You can't use a site template to customize anything more than just the fields, default views, and lists you created. You can, however, create separate List templates that will allow you make more changes. These are not a part of the site template. They are instead a different file, with the same STP extension.

Even with the disadvantages, site templates are a compelling approach to customizing Windows SharePoint Services (WSS).

0 comments: