Create a site collection in SharePoint Online

This SharePoint tutorial, we will see how to create a site collection in SharePoint Online. We will also see how to create a site collection in SharePoint Online using PowerShell and CSOM code.

We will also see how to create a site collection in SharePoint server like SharePoint 2013/2016 or SharePoint 2019.

A site collection in SharePoint is a collection of sites and subsites where users will create lists and libraries to store information and documents.

In SharePoint 2013/2016, we need to create a web application before creating a site collection. A web application is a logical unit of SharePoint site collections.

In SharePoint Online, we do not directly work with web applications, rather after setting up our Office 365 tenant, we start creating a SharePoint Online site collection.

How to create a site collection in SharePoint Online – Video Tutorial

Check out a SharePoint video tutorial I have created on how to create a site collection in SharePoint Online.

Subscribe to EnjoySharePoint YouTube channel for more SharePoint tutorials.

Create site collection SharePoint online

Now, we will see how to create a site collection in SharePoint Online modern site as well as in SharePoint Online classic experience.

Login to SharePoint Online admin center, the URL should be like below:

https://<Your tenant name>-admin.sharepoint.com/

Example: https://spskytraining-admin.sharepoint.com/

Then in the modern SharePoint Online admin center, click on Sites -> Active sites from the left navigation. Then click on +Create button like below:

create site collection sharepoint online

In SharePoint Online modern experience, we can easily create below two types of site which mostly organizations are using:

  • Team Site: A team site is used by a team to share documents, keep track of events, manage tasks, etc within your team.
  • Communication Site: A communication site is used by your organization where, you can publish dynamic, beautiful content within your organization to keep then information and engaged on topics, events or projects.

In the next screen, select Team site (if you want to create a modern team site) or communication site (if you want to create a communication site).

how to create site collection sharepoint online

Here, I have selected Team site.

Here, it will create a team site that will be connected to an Office 365 group.

Suppose you have an organization which has various departments like HR, Finance, IT, Marketing, Training etc.

You can either create one one site collection for each department or you can create one site collection for your organization and various sub sites for each department.

Here, we will create a site collection for the Finance department in the SharePoint Online portal.

Here provide the below details:

  • Site name: The name of the SharePoint site
  • Group email address: By default, it will take the SharePoint site name, but you can change it by clicking on the edit button. If the Office 365 group is not available, then you have to give a different name.
  • Site address: The site address will be auto-populated based on the site name. It will remove the space or special characters from the SharePoint site name and create the site address.
  • Group Owner: Add a group owner to the Office 365 group, the user will be the site collection administrator also.
  • Select a language: Select a language from a list of languages.
  • Privacy settings: Select Private if only members can access this site. Select Public, if anyone in the organization wants to access the site.
  • Time zone: Select a time zone.
  • Site description: Give a site description for the SharePoint site collection or site.
create site collection sharepoint online powershell

In the next screen, it will ask you to provide additional owners and members who you to have access to.

create new site collection sharepoint online

Click on Finish button and it will create the SharePoint Online team site, that you can see in the Active Sites also like below:

create modern site collection sharepoint online

If you click on the link, you can see the SharePoint team site like below:

create modern team site sharepoint online

Create site collection SharePoint online PowerShell

We can easily create a site collection in SharePoint Online using PowerShell. You can follow the below article which explains, how to create a site collection and subsite in SharePoint Online using PowerShell.

Create a site collection SharePoint Online csom

My friend wrote a good article on how to create a site collection in SharePoint programmatically using PnP CSOM.

You can follow the below tutorial, to create a modern site in SharePoint Online using PnP CSOM.

Create a site collection in SharePoint Server

We can also create a site collection in SharePoint server easily from the SharePoint central administration. The steps to create site collection is same in SharePoint 2013/2016/2019.

Below two things are required to create a site collection in SharePoint server.

  • There should be a SharePoint web application because we have to create a site collection under a particular web application.
  • The user should be a member of the farm administrator SharePoint group.

Now, Open the SharePoint central administration, from the Application Management section, click Create site collections which will open the create SharePoint site collections page.

There first select the web application under which you want to create the site collection. You can click Change Web Application link, to change the web application.

Then provide the title, description and web address of the site collection. While providing the site collection web address, you should not provide any special characters or spaces. You should follow the SharePoint naming conventions.

Then in the template selection, select a template from the list of template categories like Collaboration, Enterprise or Publishing, etc.

In SharePoint 2016 (Feature pack) or SharePoint 2019, you will see two team site template like:

  • Team site
  • Team site classic experience

Then enter the Primary site collection administrator and secondary site collection administrator, the user name will be in Domain/username format.

You can also select the Quota template for the SharePoint site collection.

Then click on OK and it will create the SharePoint site collection.

Create site collection SharePoint using PowerShell

We can also easily create a site collection in SharePoint using PowerShell using New-SPSite PowerShell cmdlets.

Below is the PowerShell command:

$template = Get-SPWebTemplate "STS#0"

New-SPSite -Url https://webApp/sites/Marketing -OwnerAlias "TSINFO\Bijay" -Language 1033 -Template $template

You can run the PowerShell script using PowerShell ISE on the SharePoint server which will create the site collection.

PnP CSOM Create site collection (Bulk Site Creation)

Let us see, how to create modern team site SharePoint Online programmatically using PnP CSOM. Here we will see how to create bulk site collection using PnP CSOM.

I have an Excel spreadsheet which contains four columns as:

  • SiteName: This helps to give a name to the new Modern SharePoint Team Site.
  • SiteURL: This defines to provide an address URL to the new Modern SharePoint Team Site.
  • SiteDescription: This assists to provide a description of the new Modern Team Site.
  • SiteStorage: It helps to store the size of a new Modern Team Site.

You can see all the columns and its all values in below Excel spreadsheet screenshot:

create modern sharepoint team site using pnp csom programmatically
create modern sharepoint team site using pnp csom programmatically

By using this above Excel sheet, we need to create SharePoint Modern Team Site in SharePoint Online using pnp csom.

For this requirement, At first, we have to retrieve the Excel Sheet and then we have to write the code for creating SharePoint Modern Team Site. For that you can follow the below-tested csom code:

public async Task ReadDataFromExcelAsync()
        {
            try
            {
                Excel.Application xlApp;
                Excel.Workbook xlWorkBook;
                Excel.Worksheet xlWorkSheet;
                Excel.Range range;

                string strSiteName,strURL,strDescription;
                double intStorage;
                int RowCount;
                int TotalRow = 0;

                xlApp = new Excel.Application();
                xlWorkBook = xlApp.Workbooks.Open(@"D:\SharePointSiteData", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
                xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

                range = xlWorkSheet.UsedRange;
                TotalRow = range.Rows.Count;

                for (RowCount = 2; RowCount <= TotalRow; RowCount++)
                {
                    strSiteName = (string)(range.Cells[RowCount, 1] as Excel.Range).Value2;
                    strURL = (string)(range.Cells[RowCount, 2] as Excel.Range).Value2;
                    strDescription = (string)(range.Cells[RowCount, 3] as Excel.Range).Value2;
                    intStorage = Convert.ToDouble((range.Cells[RowCount, 4] as Excel.Range).Value2);                   
                    lblMessage.Text = strSiteName + " " + strDescription + " " + strURL + " " + Convert.ToDouble(intStorage).ToString();                    

                    string siteUrl = "https://yourtenantname.sharepoint.com/";
                    string userName = "preeti@yourtenantname.onmicrosoft.com";
                    string passWord = "**********";

                    OfficeDevPnP.Core.AuthenticationManager authManager = new OfficeDevPnP.Core.AuthenticationManager();
                    ClientContext context = authManager.GetSharePointOnlineAuthenticatedContextTenant(siteUrl, userName, passWord);

                    bool aliasContext = await context.AliasExistsAsync(strURL);
                    if(aliasContext==false)
                    {
                        TeamSiteCollectionCreationInformation modernteamSiteInfo = new TeamSiteCollectionCreationInformation
                        {
                            DisplayName = strSiteName,
                            Description = strDescription,
                            Alias = strURL,
                            IsPublic = true,                                         
                        };
                        var createModernSite = await context.CreateSiteAsync(modernteamSiteInfo);
                        lblCreateModernSite.Text = "Modern Team Sites created successfully";
                    }
                  
                    lblCreateModernSite.Text = "This Modern Team Site is already exists";                                       
                }
                xlWorkBook.Close(true, null, null);
                xlApp.Quit();
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.StackTrace;
            }
        }

Here I have written this code in a button click, So the code will run when you will click on the button. Once you will execute this above csom code, you can see the output in the SharePoint Online Office 365 Admin Center.

The below screenshot represents all the new Modern SharePoint Team Site which are presenting in the SharePoint Online Office 365 Admin Center.

create sharepoint team site using pnp csom programmatically
create sharepoint team site using pnp csom programmatically

This is how to create multiple site collections using PnP CSOM in SharePoint Online.

You may like following SharePoint site collection tutorials:

In this SharePoint tutorial, we learned:

  • How to create site collection SharePoint Online
  • How to create a site collection in SharePoint server
  • How to create a site collection in SharePoint using PowerShell
  • How to create a site collection in SharePoint Online using PowerShell
  • How to create site collection sharepoint online using csom
  • How to create SharePoint site collection using PnP CSOM
  • PnP CSOM Create multiple site collections
>