Reading time: 2 min read

Link Field Does Not Display If "Description" AKA Anchor Text Has No Value

But Sometimes You Want To Display a Link With No Visible Text

Typically it's best practice for all links on a webpage to include anchor text to give users and search engines context about what a link is for. However, for some fields, you may not want to actually display the anchor text. One example is if you have a link to Twitter and the link appears as a Twitter icon without any visible text. This case can be problematic for Sitecore because if one checks to see if the field has a value, Sitecore will return no value if the "Description" subfield of a General Link field has no value; even if the URL does have a value. Here's some boilerplate code with a few tips and tricks to get you on your way. ## The Model

,[object Object],
,[object Object],
,[object Object],

The View



@if (ViewHelper.IsEditMode())
{
	@* Render the field directly in edit mode so that the user can visually modify the links *@
	,[object Object],
}
else
{
	@* Preview or Normal modes *@
	@* Ensure the link field has a URL which will be used to determine whether or not the link should be displayed *@
	@* Use the authored link anchortext or a default value if it is not set *@
	
	if (!String.IsNullOrWhiteSpace(Model.TwitterLinkRaw))
	{
		,[object Object],
	}
}

All the very best, Marcel