Unfortunately as of this moment, you are stuck. The only thing that can work on "Modern" site pages is custom theme.
If your site happens to use a custom theme, then this custom theme
will be respected in the "modern" page experience
Customizing "modern" site pages
What it says is that - If you developed your own theme using the SharePoint palette tool and then applied it on the site, then it will be respected.
You can use powershell code below or your CSOM code to ApplyTheme
. It will respect the theme color (spcolor
) and background image. Powershell is as below:
# Connect to a previously created Modern Site
$cred = Get-Credential
Connect-PnPOnline https://[tenant].sharepoint.com/sites/siteurl -Credentials $cred
# Apply a custom theme to a Modern Site
# First, upload the theme assets
Add-PnPFile -Path .\sppnp.spcolor -Folder SiteAssets
Add-PnPFile -Path .\sppnp-bg.png -Folder SiteAssets
# Second, apply the theme assets to the site
$web = Get-PnPWeb
$palette = $web.ServerRelativeUrl + "/SiteAssets/sppnp.spcolor"
$background = $web.ServerRelativeUrl + "/SiteAssets/sppnp-bg.png"
# We use OOTB CSOM operation for this
$web.ApplyTheme($palette, [NullString]::Value, $background, $true)
$web.Update()
# Set timeout as high as possible and execute
$web.Context.RequestTimeout = [System.Threading.Timeout]::Infinite
$web.Context.ExecuteQuery()
PnP Reference - modern-experience-customizations-customize-sites
What will not work on modern pages till now:
1) Alternative layouts
2) Custom page templates
3) Adding "classic" web parts on "modern" pages
4) Custom CSS via AlternateCSSUrl web property
5) Custom JavaScript embedded via User Custom Actions
6) Custom master pages
So as of this moment, the only way to customizing the modern pages is via themes. Everything else will not work.