If you or your client needs to be able to create short urls or links to other sites without wanting to add it as a redirect in the web config, then this is the post for you. You can create them as umbraco pages that act as fast links or redirects.

Firstly, you need to create a template for the document type to use.
I normally create on called 'FastLink'.

Here is the code I use for the template:

@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
Layout = null;
string linkUrl = "";
var linkItem = CurrentPage.linkTarget.First;
linkUrl = linkItem.link;


Now you need to create a document type, in this case I call it 'Fast Link'. Choose the Fast Link template you just created.

I would then normally create a tab called 'Information'.  Once you have created the tab, you can then create a Related Links property called 'Link Target'. The alias for this property should automatically be set to 'linkTarget'

Make sure you choose the Information tab for this property to appear in.  Once this document type is saved, you are ready to use it in your site.

To be able to add it into the structure of your site, you need to edit the document type that you would like to allow it under, i.e. your 'Home' document type. Go to the structure tab and in the allowed child nodes check box list, choose 'Fast Link'. Then hit save.

You can now create a Fast Link in the site under the home node, or whichever you set it to. When you create it, you will need to add a row to the Link Target field, by entering a caption, choosing an internal page or inputting an external url and then tick whether or not you want it to open in a new tab. (This will come in handy when using it in a menu).
Save the row and Save and Publish the document.

Next visit the url of the item you created e.g. http://www.mysite.com/test/ and it should redirect you to the page or external address you chose.

To finish this off you can use these fast links in your site menu.

Here is an example Partial which generates a site menu from the pages in your site with a simple ul > li structure:

@inherits Umbraco.Web.Mvc.UmbracoTemplatePage

var homePage = CurrentPage.AncestorsOrSelf(1).First();

<div id="navigation">
<li><a href="@homePage.Url">@homePage.Name</a></li>

@helper RenderChildren(dynamic parentPage)
var children = parentPage.Children.Where("Visible").Where("excludeFromTopNavigation != true && documentTypeAlias != \"Xmlsitemap\"");
if(children != null && children.Any() && children.Count() > 0)
foreach(var page in children)
string linkUrl = page.Url;
string linkTarget = null;
string linkCaption = page.Name;
@if(page.documentTypeAlias == "FastLink" && page.HasValue("linkTarget"))
var linkItem = page.linkTarget.First;
linkUrl = (bool)linkItem.isInternal ? Umbraco.NiceUrl(linkItem.Value<int>("internal")) : linkItem.link;
linkTarget = (bool)linkItem.newWindow ? "_blank" : null;
linkCaption = linkItem.caption;
<a href="@linkUrl" target="@(!String.IsNullOrEmpty(linkTarget) ? linkTarget : null)">@linkCaption</a>

Notice that when it identifies the document as a Fast Link, it gets the caption, target and url from the first row in the link target field. This means that when the fast link is rendered in a menu, the page can open in a new tab if the new window value was set to true.

Want to learn more about Umbraco?

Follow along with this video to get you started with Umbraco

Want to thank me?

If I've helped you out and you want to thank me, why not buy me a coffee?

About the author

Paul Seal

Umbraco MVP and .NET Web Developer from Derby (UK) who specialises in building Content Management System (CMS) websites using MVC with Umbraco as a framework. Paul is passionate about web development and programming as a whole. Apart from when he's with his wife and son, if he's not writing code, he's thinking about it or listening to a podcast about it.

Related Posts

Find out how my blog reached 1 million page views

In this post I will tell you how my blog reached 1 million page views.

Read Post

How to include scripts from partial views in MVC and Umbraco

This post will show you how you can include scripts from inside an MVC partial view rather than havi…

Read Post

How to fix the error "Authentication failed because the remote party has closed the transport stream"

This post will show you how to fix the error "Authentication failed because the remote party has clo…

Read Post

How to solve the error Could not load file or assembly System.Security.Principal.Windows

This post help you solve the error System.IO.FileNotFoundException Could not load file or assembly S…

Read Post