|
| 1 | +# Introduction |
| 2 | + |
| 3 | +The SharePoint modern user interface does handle branding differently than classic SharePoint, more in particular it simply ignores custom master page or alternate CSS configurations. You can opt to leave these configurations in place in your modernized site so it still applies to a page being shown in a classic user interface, but it's cleaner to switch back the OOB master pages and remove the alternate CSS configuration. Next to these master pages and alternate CSS settings you could have used a classic custom theme. These classic custom themes do work on both classic as modern pages, but the more future proof model is the new tenant controlled SharePoint theme which obviously also applies to both classic as modern pages. |
| 4 | + |
| 5 | +## Detecting sites using master pages or alternate CSS, which is incompatible the modern user interface |
| 6 | + |
| 7 | +The recommended approach to find out which sites use a custom master page or use the alternate CSS option is running the [SharePoint "Modern" user interface experience scanner](https://github.com/SharePoint/PnP-Tools/tree/master/Solutions/SharePoint.UIExperience.Scanner). This tool will perform a deep analysis of all the sites in your tenant and create reports giving you details on sites still have incompatible master pages or alternate CSS settings. Based on the scanner output you can remediate these sites. |
| 8 | + |
| 9 | +Below is a PnP PowerShell script that shows how to revert back to the default configuration: |
| 10 | + |
| 11 | +```PowerShell |
| 12 | +$minimumVersion = New-Object System.Version("2.24.1803.0") |
| 13 | +if (-not (Get-InstalledModule -Name SharePointPnPPowerShellOnline -MinimumVersion $minimumVersion -ErrorAction Ignore)) |
| 14 | +{ |
| 15 | + Install-Module SharePointPnPPowerShellOnline -MinimumVersion $minimumVersion -Scope CurrentUser |
| 16 | +} |
| 17 | +Import-Module SharePointPnPPowerShellOnline -DisableNameChecking -MinimumVersion $minimumVersion |
| 18 | +
|
| 19 | +Connect-PnPOnline -Url "<your site url>" |
| 20 | +
|
| 21 | +# Set out-of-the-box master page |
| 22 | +Set-PnPMasterPage -MasterPageSiteRelativeUrl _catalogs/masterpage/seattle.master -CustomMasterPageSiteRelativeUrl _catalogs/masterpage/seattle.master |
| 23 | +
|
| 24 | +# Remove the alternate CSS setting |
| 25 | +$web = Get-PnPWeb -Includes AlternateCssUrl |
| 26 | +$web.AlternateCssUrl = "" |
| 27 | +$web.Context.ExecuteQuery() |
| 28 | +``` |
| 29 | + |
| 30 | +## Using a tenant controlled SharePoint theme |
| 31 | + |
| 32 | +SharePoint offers a series of default themes out-of-the-box which you can use, but if you want to push your company branding it's recommended that you create your company theme and hide the out-of-the-box themes. Once that configuration is done your users can only select from the company SharePoint themes you've configured and you can programmatically set such a company SharePoint theme as part of the modernization effort. |
| 33 | + |
| 34 | +Sample PnP PowerShell script showing how to add a company SharePoint theme |
| 35 | + |
| 36 | +```PowerShell |
| 37 | +$minimumVersion = New-Object System.Version("2.24.1803.0") |
| 38 | +if (-not (Get-InstalledModule -Name SharePointPnPPowerShellOnline -MinimumVersion $minimumVersion -ErrorAction Ignore)) |
| 39 | +{ |
| 40 | + Install-Module SharePointPnPPowerShellOnline -MinimumVersion $minimumVersion -Scope CurrentUser |
| 41 | +} |
| 42 | +Import-Module SharePointPnPPowerShellOnline -DisableNameChecking -MinimumVersion $minimumVersion |
| 43 | +
|
| 44 | +Connect-PnPOnline -Url "<your tenant admin url>" |
| 45 | +
|
| 46 | +# Define your company theme colors |
| 47 | +$themepalette = @{ |
| 48 | + "themePrimary" = "#00ffff"; |
| 49 | + "themeLighterAlt" = "#f3fcfc"; |
| 50 | + "themeLighter" = "#daffff"; |
| 51 | + "themeLight" = "#affefe"; |
| 52 | + "themeTertiary" = "#76ffff"; |
| 53 | + "themeSecondary" = "#39ffff"; |
| 54 | + "themeDarkAlt" = "#00c4c4"; |
| 55 | + "themeDark" = "#009090"; |
| 56 | + "themeDarker" = "#005252"; |
| 57 | + "neutralLighterAlt" = "#f8f8f8"; |
| 58 | + "neutralLighter" = "#f4f4f4"; |
| 59 | + "neutralLight" = "#eaeaea"; |
| 60 | + "neutralQuaternaryAlt" = "#dadada"; |
| 61 | + "neutralQuaternary" = "#d0d0d0"; |
| 62 | + "neutralTertiaryAlt" = "#c8c8c8"; |
| 63 | + "neutralTertiary" = "#a6a6a6"; |
| 64 | + "neutralSecondaryAlt" = "#767676"; |
| 65 | + "neutralSecondary" = "#666666"; |
| 66 | + "neutralPrimary" = "#333"; |
| 67 | + "neutralPrimaryAlt" = "#3c3c3c"; |
| 68 | + "neutralDark" = "#212121"; |
| 69 | + "black" = "#000000"; |
| 70 | + "white" = "#fff"; |
| 71 | + "primaryBackground" = "#fff"; |
| 72 | + "primaryText" = "#333" |
| 73 | + } |
| 74 | +
|
| 75 | +# Add the company theme |
| 76 | +Add-PnPTenantTheme -Identity "CustomCompanyTheme" -Palette $themepalette -IsInverted:$false |
| 77 | +``` |
| 78 | + |
| 79 | +To use the this company SharePoint theme you can use the below script: |
| 80 | + |
| 81 | +```PowerShell |
| 82 | +$minimumVersion = New-Object System.Version("2.24.1803.0") |
| 83 | +if (-not (Get-InstalledModule -Name SharePointPnPPowerShellOnline -MinimumVersion $minimumVersion -ErrorAction Ignore)) |
| 84 | +{ |
| 85 | + Install-Module SharePointPnPPowerShellOnline -MinimumVersion $minimumVersion -Scope CurrentUser |
| 86 | +} |
| 87 | +Import-Module SharePointPnPPowerShellOnline -DisableNameChecking -MinimumVersion $minimumVersion |
| 88 | +
|
| 89 | +Connect-PnPOnline -Url "<your site url>" |
| 90 | +
|
| 91 | +# Set the company theme |
| 92 | +Set-PnPWebTheme -Theme "CustomCompanyTheme" |
| 93 | +``` |
| 94 | + |
| 95 | +## Learn more |
| 96 | + |
| 97 | +You can find all the details in the [SharePoint site theming](https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/site-theming/sharepoint-site-theming-overview) article. |
0 commit comments