0

I have about 10 site collections on SharePoint 2016 on-prem that I want to brand with our custom .css. I have the .css working great in one of the site collections, but I'm curious about how to apply to the rest of the site collections.

Here's how I link the .css in my master page :

<link rel="stylesheet" type="text/css" href="<% $SPUrl:~SiteCollection/Style Library/Susan.css%>" runat="server"/>

Is there a way to use the .css across site collections?

2

You can set location of CSS file through PowerShell:

$site = Get-SPSite https://mysitecollection
foreach ($web in $site.AllWebs)
{

    $web.AlternateCssUrl  = $site.Url + "/Style Library/Susan.css"
    $web.Update();
    Write-Host "Set CSS for site " + $web.Url
}

$site.Dispose()

EDIT:

Here is a solution without PowerShell. You basically create a copy of your master page, modify it with your CSS file and use that as master page for your all sites. Please take note of creating a copy of the master page as it's basically a bad idea to modify stuff that's in use by SharePoint.

Then afterwards you just have to set the new master page across your site collections.

  • sorry, I forgot to mention I'm trying to do this without PowerShell. (Long boring story about it) for our 2016 on -prem sites. – Susan Feb 14 at 13:25
  • OK I have updated my answer. – LeonidasFett Feb 14 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.