In SharePoint, we have lists and libraries for collaboration purposes. The lists and libraries contain a huge number of columns.SharePoint-2013-Hosting1

For better understanding and reusability, these are grouped in content types.

Content types are, hence, reusable collections of metadata which can be attached to any list or library. They help us to organize and handle the data in a better and more efficient way.

There are 2 types of content types.

  • Site Content types
    This is present in the root level of the site which can be used by subsequent subsites and lists/ libraries.
  • List Content types
    These are associated with lists and libraries and are a subset of site content types.

Let’s take an example where content types are required.

Suppose, we have an Employee site which contains list like EmployeeData, HREmployeeData, FinanceEmployeeData, EmployeeDocuments, HRDocuments.

In this case, as we can see for EmployeeData and HR EmployeeData, we can have similar columns related to employees (For example, Firstname, Lastname, Ph Number, Address). So, here there are 2 possibilities.

  • We can either create a parent content type as Employee(which contains basic Employee details). Then, create HREMPContenttype and EMPContentype which will inherit from Employee.
  • Or, we can create a content type Employee and add that in the 2 lists. Then, add additional columns for the respective list.

Same goes for documents as well.

Now comes a situation where we need the same content types or a few of them in a separate site.

In on-premise, we have a content type hub for publishing the content type to be used across multiple locations. But, in SP Online we do not have the feature.

There is an option to export and import content type.

In the below PowerShell CSOM code, we can export the content type in XML file and use in the respective sites as required.

Please store the DLLs in respective ISAPI folder before proceeding with the code.

Similarly, we can import the respective content types to a destination site collection using the below script.