Adding a Custom Web Part to a Site Definition

Adding a Custom Web Part to a Site Definition

I had to do this today and having looked around on the internet finding lots of conflicting examples, I thought I’d post the code that I used on here.

Basically what you need to do, is open the ONET.xml for your Site Definition.

Inside the ONET.xml file you will find a section called <Modules>, inside here should be a default module of some kind: <Module Name=”Default” Url=”" Path=”">.

It is inside here that you need to add the web part, to add a custom web part use the code below:

<AllUsersWebPart WebPartZoneID=”Left” WebPartOrder=”1″><![CDATA[
    <WebPart xmlns=”″ >
    <Title>’Title of Your Web Part’</Title>
    <Description>’Description For Your Web Part’</Description>
    <Assembly>Full Assembly (DLL) Details</Assembly>

Ensure that you put the full Assembly details in the <Assembly> Tag and the Class Name inside the <TypeName> Tag.

Perform an IISRESET and your done!

Footnote: You will only see the Web Part on new sites that you create and not existing ones.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">