Get SiteInfo or site name from Sitecore item

adminSitecore1 Comment

Following code does help to find SiteInfo and site name of current or provided Sitecore item


public static SiteInfo GetSiteInfo(this Item item)
    var siteInfoList = Sitecore.Configuration.Factory.GetSiteInfoList();

    return siteInfoList.FirstOrDefault(info => item.Paths.FullPath.StartsWith(info.RootPath));

public static string GetSiteName(this Item item)
    var info = item.GetSiteInfo();
    return info != null ? info.Name : string.Empty;


One Comment on “Get SiteInfo or site name from Sitecore item”

  1. Thanks Jignesh,
    This helped me get a starting point.
    Appreciate your blogpost. I edited my implementation a bit

    return siteInfoList.FirstOrDefault(info => item.Paths.FullPath.StartsWith(info.RootPath + info.StartItem, StringComparison.InvariantCultureIgnoreCase));

Leave a Reply

Your email address will not be published. Required fields are marked *