Skip to content

Instantly share code, notes, and snippets.



Last active Sep 10, 2015
What would you like to do?
Sitecore Friendly URL Computed Field
using System.Xml;
using Sitecore.ContentSearch;
using Sitecore.ContentSearch.ComputedFields;
using Sitecore.Data.Items;
using Sitecore.Links;
using Sitecore.Xml;
namespace MikeRobbins.ContentSearch.ComputedFields
public class FriendlyUrl : AbstractComputedIndexField
public override object ComputeFieldValue(IIndexable indexable)
var scIndexable = indexable as SitecoreIndexableItem;
if (scIndexable != null)
var item = (Item)scIndexable;
if (item != null)
var opts = LinkManager.GetDefaultUrlOptions();
opts.Site = Sitecore.Sites.SiteContext.GetSite(SiteName);
return LinkManager.GetItemUrl(item, opts);
return null;
public FriendlyUrl()
public FriendlyUrl(XmlNode configurationNode) : this()
SiteName = XmlUtil.GetAttribute("siteName", configurationNode);
public string SiteName { get; set; }
<fields hint="raw:AddComputedIndexField">
<field fieldName="urllink" siteName="SiteName">MikeRobbins.ContentSearch.ComputedFields.FriendlyUrl,MikeRobbins.ContentSearch</field>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment