|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
How to: Add a Content Type to a Site
This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
You can specify content types to include in a site definition, so that each time a user provisions a site of that type, Windows SharePoint Services makes those site content types available on the site by default.
Site definitions can be included in Features. For more information, see Working with Features.
After a user provisions a site, you can add content types to that site through the Windows SharePoint Services object model.
To specify a content type to include in a site definition, you first create the content type as a separate Feature, and then reference that Feature in the site definition.
To specify a content type to included in a site definition
Create the content type as a separate Feature.
For more information, see Working with Features.
Reference that Feature in the feature that defines your site:
In your site Feature, open the XML file that defines your site.
In the Project element, under the Categories and Category elements, add a reference to the content type Feature in either the SiteFeatures or WebFeatures element. For example:
<Feature ID="00BFEA71-1C5E-4A24-B310-BA51C3EB7A57" />
<Feature ID="695B6570-ACDC-4A8E-8545-26EA7FC1D162" />
<Feature ID="00BFEA71-4EA5-48D4-A4AD-7EA5C011ABE5" />
<Feature ID="00BFEA71-E717-4E80-DEAF-D0C71B360101" />
You can add content types to a provisioned site through the Windows SharePoint Services object model.
To add a content type to a provisioned site
Create a SPContentType object using the SPContentType method.