Get SiteInfo or site name from Sitecore item 1

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. Reply Praful Memane Jul 12,2016 10:07 pm

    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