Article
1 comment

Site logo inheritance on sub webs

Be careful when you change the title or the description in SharePoint you might set a logo url. Even if you don’t need to set one. Recently I found a strange behaviour in SharePoint during a branding project. The project included three site collections where each of those should have a different logo.
Somehow the logo couldn’t be changed in the complete site collection. A changed logo in the root of the site collection was not reflected on the sub site. Strange behaviour thou, because SharePoint has something that I call logo inheritance.

Break logo inheritance

So by default the sub sites inherit the logo from the root web of a site collection.

Logo setting on top page

Logo setting on top page

Any change on this dialog will apply the logo to the sub web instead of taking it from the site collection. If accidentally this dialog was opened just-to-look. The OK-Button will store the image url in the sub web.

Avoid custom web logos on sub sites

Whenever a change of title or description is needed. Make sure that the address field was cleaned and empty.

Always clear logo before save the setting

Always clear logo before save the settings

Don’t worry if you do this. The logo will be replaced in the dialog to the default on. After the properties was committed to the server. The correct logo, the one of the site collection, shows up again.

For branding solutions

The same thing applies if you develop a branding solution or feature stapling. Never set the logo url on a sub site in case you like to change it afterwards. If you take a team site for example. This kind of web template doesn’t inherit anything. You can inherit the branding of the root web site with the following lines of code.

// Set the same properties as in sub web
subWeb.MasterUrl = rootWeb.MasterUrl;
subWeb.CustomMasterUrl = rootWeb.CustomMasterUrl;
subWeb.AlternateCssUrl = rootWeb.AlternateCssUrl;

// Activate MasterPage and CSS inheritance
subWeb.AllProperties[Constants.InheritsAlternateCssUrl] = "True";
subWeb.AllProperties["__InheritsCustomMasterUrl"] = "True";
subWeb.AllProperties["__InheritsMasterUrl"] = "True";
subWeb.AllProperties["__InheritsAlternateCssUrl"] = "True";

// Empty Site Logo Url to inherit from parent web
subWeb.SiteLogoUrl = String.Empty;
subWeb.Update();

The last part of empties the logo url. This makes sure that the logo was taken from the parent website.

Fix Messed up site logos

If you are not sure and like to change the logo of an existing site collection you can use the following PowerShell script.
This script can also be applied when the logos of the sub site should be simply reset.

[CmdletBinding()]
    Param (
        [Parameter(Mandatory=$True,Position=1)]
        [string]$sc
    )

    $spsite = Get-SPsite $sc 

    foreach ($web in $spsite.AllWebs)
    {   
        # Check if the current site is not root web
        # preserves the logo of the site collection
        if ($web.IsRootWeb -ne $true) {
            write-host $web.Title " ... " -nonewline;
            $web.SiteLogoUrl = ""
            $web.update()
            $web.dispose()        
            write-host "removed" -foreground green
        }
    }
    $spsite.dispose()

 

1 Comment so far

Leave a Reply

Required fields are marked *.


This site uses Akismet to reduce spam. Learn how your comment data is processed.