SharePoint 2010 Create a custom site definition

Ever wanted to create your own custom site definition? It’s pretty cool, if you can choose your own template at the time you create a site collection at the central administration. What can you by using a solution with a custom site definition?

Well, at first you can define fields, content types, lists, libraries and webparts which should be available after site is created. Of course, what was important for me, was the possibility to change the default.aspx page which is the starting point. At the default.aspx which is the entry point of each site collection you can place webparts, text, images, etc.

So  if you are creating your own site definition don’t leave it blank. Use an image and a welcome text. Maybe you can provide a small intoduction into this workspace and necessary contact information if the user needs help. Useful links might be also interesting. Your user should have a good feeling when starting with SharePoint. My desired solution should have a custom image and a welcome text.

Ok, that’s enough explanation. Let’s go into the details.

At first you create a new Visual Studio project and choose as template the site definition. After that your project contains an area with three elements. The onet.xml, the webtemp_mySitedefinition.xml and the default.aspx. So let’s have a look at the webtemp_mySitedefinition.xml file.


< ?xml version="1.0" encoding="utf-8"?>
<templates xmlns:ows="Microsoft SharePoint">
<template Name="My.ProjectSiteDefinition" ID="10000">
<configuration ID="0" Title="My Projects" Hidden="FALSE"
Description="Project Template for Me"

At first we set a template name and an ID. We set a configuration ID and a title. That’s it for this time. This definition makes that you have a title and a description and a category if you choose the template for subsite like the screen makes it clear.Sitedef1

After that we should look at the onet.xml file. There is a little bit more logic in it. At first you have to define the project definition, the navbars and then the configuration.

Navbars: In this section you can define which links in the quicklaunch or the top menu should be displayed by default.

Configuration: You can setup several configurations. In each configuration you can define lists, features and the default page. Each Configuration has an ID.

Lists: In this section you can define which lists should be available, for example if you defined your own list schema.

Web and Site features: These are the features which should be activated by default. So I recommend to use some standard features, so that your site provides the templates to create new lists (task, etc.)

Build up the Default.aspx or Homepage

Modules: This is interesting. You define a module name, and later on we define what should happen. So as you can see we add a file default.aspx. After that we open the tag all users webpart and can define the whole page content, like pictures, welcome text and so on. The basics, of course, is the default.aspx page, but here we put the content of the default.aspx page.

Update: DO NOT DELETE <navbar Name=”SharePoint Top Navbar” ID=”1002″></navbar> from Navbars!!!


< ?xml version="1.0" encoding="utf-8"?>
<project Title="My.ProjectSiteDefinition" Revision="2" ListDir="" xmlns:ows="Microsoft SharePoint" xmlns="">
<!-- This one is important, do not delete it! -->
<navbar Name="SharePoint Top Navbar" ID="1002"></navbar>
<navbar Name="Libraries" Url="_layouts/viewlsts.aspx?BaseType=1" ID="1004"></navbar>
<navbar Name="Lists" Url="_layouts/viewlsts.aspx?BaseType=0" ID="1003">

<configuration ID="0" Name="My.ProjectSiteDefinition">
<!-- BasicWebParts Feature -->
<feature ID="00BFEA71-1C5E-4A24-B310-BA51C3EB7A57"></feature>
<!-- Three-state Workflow Feature -->
<feature ID="FDE5D850-671E-4143-950A-87B473922DC7"></feature>
<!-- TeamCollab Feature -->
<feature ID="00BFEA71-4EA5-48D4-A4AD-7EA5C011ABE5"></feature>
<!-- MobilityRedirect -->
<feature ID="F41CC668-37E5-4743-B4A8-74D1DB3FD8A4"></feature>
<!-- WikiPageHomePage Feature -->
<feature ID="00BFEA71-D8FE-4FEC-8DAD-01C19A6E4053"></feature>
<module Name="DefaultBlank"></module>
<module Name="DefaultBlank" Url="" Path="">
<file Url="default.aspx" NavBarHome="True">
<!-- Add a Web Part to left zone -->
<alluserswebpart WebPartZoneID="Left" WebPartOrder="0">
< ![CDATA[
<assembly>Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c</assembly>
&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;h1 class=&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;ms-rteElement-H1&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;quot;&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;Herzlich Willkommen in Ihrem Workspace!&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;lt;/h1&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;gt;



<!-- Bild -->
<alluserswebpart WebPartZoneID="Right" WebPartOrder="1">
< ![CDATA[
<WebPart xmlns:xsi="" xmlns:xsd="" xmlns="">
<description>TenneT Picture</description>
<assembly>Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c</assembly>
<imagelink xmlns="">_layouts/images/AccessProjects.png</imagelink>
<alternativetext xmlns=""></alternativetext>
<verticalalignment xmlns="">Middle</verticalalignment>
<horizontalalignment xmlns="">Center</horizontalalignment>
<backgroundcolor xmlns="">transparent</backgroundcolor>



That’s about the definitions, now we build up the template for the default aspx page. You can just copy and paste it, we define a table with two columns. Each column has a webpart zone.


< %@ Page language="C#" MasterPageFile="~masterurl/default.master" Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint,Version=,Culture=neutral,PublicKeyToken=71e9bce111e9429c"  %>
< %@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
< %@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
< %@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
< %@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
< %@ Import Namespace="Microsoft.SharePoint" %>
< %@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
< %@ Assembly Name="Microsoft.Web.CommandUI, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<asp:content ContentPlaceHolderId="PlaceHolderPageTitle" runat="server">
<sharepoint:projectproperty Property="Title" runat="server"></sharepoint:projectproperty>

<asp:content ID="Content1" ContentPlaceHolderId="PlaceHolderMain" runat="server">
<table width="100%" cellpadding=0 cellspacing=0 style="padding: 5px 10px 10px 10px;margin-top:5px;">
<td id="_invisibleIfEmpty" name="_invisibleIfEmpty" valign="top" height="100%" width="60%">
<webpartpages:webpartzone runat="server" Title="loc:Left" ID="Left" FrameType="TitleBarOnly"><zonetemplate></zonetemplate></webpartpages:webpartzone> </td>
<td id="_invisibleIfEmpty" name="_invisibleIfEmpty" valign="top" height="100%" >
<webpartpages:webpartzone runat="server" Title="loc:Right" ID="Right" FrameType="TitleBarOnly"><zonetemplate></zonetemplate></webpartpages:webpartzone> </td>
<script type="text/javascript" language="javascript">if(typeof(MSOLayout_MakeInvisibleIfEmpty) == "function") {MSOLayout_MakeInvisibleIfEmpty();}</script>

After deployment you can choose your template if you create a subsite in your site collection and you can choose the template if you’re creating a site collection in the central administration.



After you created a subsite or a new site collection, you will see a site page like this:



The article or information provided here represents completely my own personal view & thought. It is recommended to test the content or scripts of the site in the lab, before making use in the production environment & use it completely at your own risk. The articles, scripts, suggestions or tricks published on the site are provided AS-IS with no warranties or guarantees and confers no rights.

Karsten Schneider
About Karsten Schneider 302 Articles
He is Consultant for SharePoint Solutions for collaboration, communication and business processes. He provides his customers applications based on standard features as well as development or combining the power of several microsoft tools like Dynamics CRM. In his free time he tries to collect tipps and worthy experience in this blog.

Be the first to comment

Leave a Reply

Your email address will not be published.