SharePoint / Guide 10

Library schemas and content type IDs

Content type IDs from 0x down, list templates, schema.xml, and building custom libraries the right way.

Every list and library in SharePoint is defined by a list template (what kind of list it is) and a set of content types (what kinds of items it holds). Content type IDs, the long values starting with 0x, encode the whole inheritance chain. Once you can read them, a lot of SharePoint's behaviour makes sense.

Content type IDs: reading the 0x

A content type ID is a hexadecimal string that contains its parent's ID. Reading from the left, you can see every ancestor:

0x                      System (the root of everything)
0x01                    Item
0x0101                  Document          (Item + 01)
0x010101                Form              (Document + 01)
0x0120                  Folder            (Item + 20)
0x0120D520              Document Set      (Folder + D520)

So a content type whose ID starts with 0x0101 is a kind of Document, and anything starting with 0x0120 is a kind of Folder.

Well-known content type IDs

ID Content type
0x System
0x01 Item
0x0101 Document
0x010101 Form
0x010102 Picture
0x010105 Master Page
0x010108 Wiki Page
0x010109 Basic Page
0x01010901 Web Part Page
0x01010A Link to a Document
0x0102 Event
0x0103 Issue
0x0104 Announcement
0x0105 Link
0x0106 Contact
0x0107 Message
0x0108 Task
0x0109 Workflow History
0x0120 Folder
0x012002 Discussion
0x0120D520 Document Set

Check any of these in your own site with the snippets at the end of this guide; Microsoft adds new built-in content types over time.

Building your own IDs

There are two ways to extend an ID:

  1. Parent ID + two hex digits (not 00), for example 0x0101 + 01 = 0x010101. Microsoft uses this for built-in types, so avoid it for your own.
  2. Parent ID + 00 + a GUID without dashes. This is the right way for custom content types, because the GUID guarantees uniqueness:

0x0101 00 A1B2C3D4E5F6478890ABCDEF12345678 = 0x010100A1B2C3D4E5F6478890ABCDEF12345678 "Contract", based on Document

A child of that type then adds two digits: 0x010100A1B2C3D4E5F6478890ABCDEF1234567801 for "Supplier contract".

Content type IDs can be up to 1,024 characters long, so deep hierarchies are possible. In practice, keep them to two or three levels.

When a content type is added to a list, SharePoint creates a list content type as a child of the site content type, so its ID in the list is longer than the site version. That's normal: code should compare with "starts with" rather than "equals".

List templates and base types

Every list is created from a list template, identified by a number (BaseTemplate), and belongs to a BaseType.

BaseTemplate List template
100 Custom list
101 Document library
102 Survey
103 Links
104 Announcements
105 Contacts
106 Calendar (events)
107 Tasks (2010 style)
108 Discussion board
109 Picture library
115 Form library (InfoPath)
116 Master page gallery
119 Wiki page library (Site Pages)
130 Data connection library
140 Workflow history
150 Project tasks
170 Promoted links
171 Tasks (2013 and later)
850 Pages library (publishing)
851 Asset library
1100 Issue tracking
BaseType Meaning
0 Generic list
1 Document library
3 Discussion board (legacy)
4 Survey
5 Issue

Inside a library definition (schema.xml)

On SharePoint Server, the out-of-the-box document library is defined in the hive under TEMPLATE\FEATURES\DocumentLibrary\DocLib\schema.xml. A list definition has four main parts:

  • <ContentTypes>: which content types the library starts with (for a document library, Document 0x0101 and Folder 0x0120).
  • <Fields>: columns defined only for this list.
  • <Views>: the views, written in CAML.
  • <Forms>: the display, edit and new forms.

The feature's elements.xml registers the template with a <ListTemplate> element that gives it a Type (the BaseTemplate number), a BaseType, a name and an icon.

Don't edit the built-in schema.xml files. Changes are overwritten by updates and make upgrades fail.

Some core document library columns you'll meet in CAML, PowerShell and REST (use the internal name):

Internal name Meaning
FileLeafRef File name
FileRef Server-relative URL
ContentTypeId The item's content type ID
FSObjType 0 = file, 1 = folder
_UIVersionString Version label, e.g. 3.0
CheckoutUser Who has it checked out
Author / Editor Created by / Modified by

Custom library templates: four approaches

1. Save as template (.stp). List settings > Save list as template stores the library (optionally with content) in the List Template Gallery (BaseTemplate 114). Quick, but tied to the site's features and language, and not suitable for repeatable deployment.

2. Feature-based list definition (farm solution). A <ListTemplate> plus your own schema.xml, deployed in a WSP. This was the standard approach in 2007 and 2010. It works only on-premises, and custom list definitions make upgrades and migrations harder, so avoid it for new work.

3. Content types + provisioning (recommended). Create the library from the standard Document Library template (101), and add your site columns and content types with a provisioning script. The library stays "standard", so upgrades and migrations stay simple. PnP provisioning templates make this repeatable:

# Capture from a reference site
Get-PnPSiteTemplate -Out .\ContractsLibrary.xml -Handlers Fields, ContentTypes, Lists
# Apply to a new site
Invoke-PnPSiteTemplate -Path .\ContractsLibrary.xml

4. SharePoint Online site scripts and list templates. In Microsoft 365, site scripts (createSPList action) and custom list templates (Add-SPOListDesign) let users create your library from the "New" menu, with your columns and views already in place.

Explore content types with PowerShell

SharePoint Server:

$web = Get-SPWeb https://sharepoint.ravindran.in/sites/HR
$web.ContentTypes |
    Select-Object Name, @{n='Id';e={$_.Id.ToString()}}, @{n='Parent';e={$_.Parent.Name}}, Group, Hidden |
    Sort-Object Id | Format-Table -AutoSize
$web.Dispose()

Which content types a library uses:

$web  = Get-SPWeb https://sharepoint.ravindran.in/sites/HR
$list = $web.Lists["Documents"]
$list.ContentTypes | Select-Object Name, @{n='Id';e={$_.Id.ToString()}}
"BaseTemplate: $($list.BaseTemplate)  BaseType: $($list.BaseType)"
$web.Dispose()

SharePoint Online (PnP.PowerShell):

Connect-PnPOnline -Url https://sharepointonline.ravindran.in/sites/HR -ClientId $env:PNP_CLIENT_ID -Interactive
Get-PnPContentType | Select-Object Name, @{n='Id';e={$_.Id.StringValue}}, Group | Sort-Object Id
Get-PnPContentType -List "Documents"