SharePoint Online: Team site is not responsive

Scenario: My team site is not responsive on mobile devices

  • If you have an existing custom master page, by using Custom Master Page and provision script to apply it
    PnP Example:

    #enable publishing feature on all sites
    
    $subWebs = Get-SPOSubWebs
    foreach ($web in $subWebs) {
    	Enable-SPOFeature -Identity "94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb" `
                              -Force -Web $web.ServerRelativeUrl
    }
    #Add/update the master page
    Add-SPOMasterPage -SourceFilePath "C:/temp" -Title "master.aspx" `
                      -Description "customer master page" `
                      -DestinationFolderHierarchy "test" -UiVersion 15
    
    #Apply it on the root site
    Set-SPOMasterPage -MasterPageServerRelativeUrl $MasterPageServerRelativeUrl `
    		  -CustomMasterPageServerRelativeUrl $MasterPageServerRelativeUrl
    
    #Apply it to all subsites
    $MasterPageServerRelativeUrl = "/_catalogs/masterpage/test/master.aspx"
    $subWebs = Get-SPOSubWebs
    foreach ($web in $subWebs) {
    Set-SPOMasterPage -MasterPageServerRelativeUrl $MasterPageServerRelativeUrl `
                -CustomMasterPageServerRelativeUrl $MasterPageServerRelativeUrl `
      	    -Web $web.ServerRelativeUrl
    }
    
    
  • Register Site Action and use jQuery to apply responsive elements: e.g: https://github.com/SharePoint/PnP-Tools/tree/master/Solutions/SharePoint.UI.Responsive, but if you already have customized publishing site, you might have to modify the scripts to apply these responsive actions only to certain site templates.
  •     .\Enable-SPResponsiveUI.ps1 -TargetSiteurl "https://intranet.mydomain.com/sites/targetSite"
    
  • Using SPMeta2, example code snippet
    
     public ModelNode GetModel()
     {            
           var model = SPMeta2Model.NewWebModel(rootWeb =>
           {
               rootWeb.AddWeb(intranetWebs.TeamSites, web =>
               {
                    web.AddMasterPageSettings(intranetMasterPages.masterPageSettings);
                      
               });
           });
           return model;
    }
    
    public static class intranetMasterPages
    {
        public static MasterPageSettingsDefinition masterPageSettings = new MasterPageSettingsDefinition
        {
            // both should be site relative URLs
            SiteMasterPageUrl = "/_catalogs/masterpage/Intranet.master",
            SystemMasterPageUrl = "/_catalogs/masterpage/Intranet.master"
            //"/_catalogs/masterpage/seattle.master"
        };
    }
    
  • More(TBA)…

Leave a comment