How to Change the Look of SharePoint using CSOM

  • Posted by: Softree Technology

This blog will help you how to change SharePoint look programmatically using CSOM. In SharePoint we can manually change the site collection look through Navigating Site setting -> Look and feel -> Change the look. Select the template that you want to keep.

To change the SharePoint look programmatically, first, we have to get Theme Url, Image Url,Font Scheme URL of templates. we can get it in Composed Looks list.you can get it navigating through “Siteurl + /_catalogs/design/AllItems.aspx” .

Below image shows Composed Looks list which contains different templates with different theme url,image url,font scheme url.

The code block for this is as mentioned below”

using System;
using System.Net;
using Microsoft.SharePoint.Client;

namespace ApplyTheme
{
class Program
{
static void Main(string[] args)
{
ClientContext ctx = new ClientContext("http://portal/sites/site1");
Web web = ctx.Web;
NetworkCredential cred = new NetworkCredential("user@domain.com","password");
ctx.Credentials = cred;
ctx.Load(web);
ctx.ExecuteQuery();
var themeUrl = web.ServerRelativeUrl + "/_catalogs/theme/15/palette008.spcolor";
var fontSchemeUrl = web.ServerRelativeUrl + "/_catalogs/theme/15/fontscheme003.spfont";
var imageUrl = web.ServerRelativeUrl + "/_layouts/15/images/image_bg008.jpg";
web.ApplyTheme(themeUrl, fontSchemeUrl, imageUrl, true);
web.Update();
ctx.ExecuteQuery();
}
}
}

I have changed the SharePoint look to sketch template type. After code executed successfully you can see site collection look has been changed successfully.

This solution is brought to you by our SharePoint professionals.

Softree Technology employs SharePoint consultants; we are a technology services provider with the aim to help companies achieve exceptional performance through SharePoint. Our dedicated team of SharePoint consultants has the right bent of mind to understand and execute customer requirements.

Be it SPFx or SharePoint add-in developments, SharePoint 2019 developments, web part developments, migrating from SharePoint 2010/2013 to SharePoint 2013/2016/Office 365, Office 365, SharePoint hosted apps development or something else in SharePoint, we strive to deliver the best

Author: Softree Technology

Leave a Reply