SharePoint Redirect site logo link to the root site collection home page

sharepointsharepoint-2013

I want the site logo link in the master page to always redirect to the root site collection home page. Default behavior is to redirect to the homepage of the current web (spweb).

Back in SharePoint 2010 I could accomplish this by adding the NavigateUrl attribute to the SPLinkButton control in the master page with a value of ~sitecollection like this:

<SharePoint:SPLinkButton runat="server" NavigateUrl="~sitecollection/" id="onetidProjectPropertyTitleGraphic">
<SharePoint:SiteLogoImage name="onetidHeadbnnr0" id="onetidHeadbnnr2" LogoImageUrl="/_layouts/images/siteIcon.png" runat="server"/>
</SharePoint:SPLinkButton>

However in SharePoint 2013 the control for the site logo link has changed in the master page to SPSimpleSiteLink. I have tried setting the NavigateUrl property for this control in the same way but it does not seem to work anymore.

<div id="siteIcon" class="ms-tableCell ms-verticalAlignTop">
  <SharePoint:AjaxDelta id="DeltaSiteLogo" BlockElement="true" runat="server">
    <SharePoint:SPSimpleSiteLink NavigateUrl="~sitecollection/" CssClass="ms-siteicon-a" runat="server" id="onetidProjectPropertyTitleGraphic" >
      <SharePoint:SiteLogoImage CssClass="ms-siteicon-img" name="onetidHeadbnnr0" id="onetidHeadbnnr2" LogoImageUrl="/_layouts/15/images/siteIcon.png?rev=23" runat="server"/>
    </SharePoint:SPSimpleSiteLink>
  </SharePoint:AjaxDelta>
</div>

As a workaround, I have now removed the AjaxDelta wrapper control and changed the SPSimpleSiteLink to the old SPLinkButton with the added NavigateUrl attribute. This seem to work.

Are there any better ways?

Best Answer

Regarding MSDN SharePoint:SPSimpleSiteLink is a "very simple control which provides a link to the current site This control is compliant as a chrome control in an MDS-enabled master page"

if you want the site logo link always redirect to the site collection root site, use SharePoint:SiteLogoImage (as we was used with SP 2010)

<SharePoint:AjaxDelta id="DeltaSiteLogo" BlockElement="true" runat="server">
<SharePoint:SPLinkButton runat="server" NavigateUrl="~sitecollection/" id="onetidProjectPropertyTitleGraphic">
                    <SharePoint:SiteLogoImage  name="onetidHeadbnnr0" id="onetidHeadbnnr2" LogoImageUrl="images/logo.png" runat="server">
                                </SharePoint:SiteLogoImage>
              </SharePoint:SPLinkButton>

Related Topic