Sitecore Broken Links Are Not 404, and You Should Be Checking for This Setting Before Going Live

You know the deal. Before going live, you check for all possible use cases in your site, including 404 URLs. You'd assume broken links will route a User to said 404 pages, but you'd be wrong, and the result won't be what your content team is looking for.

Sitecore does a good enough job at displaying an explanation for missing items if you don't implement a change from the OOTB solution, but it's far from ideal. The result is a unilingual, unbranded page that may not be clear for the entire audience. 

How to Replicate a Not Found Page Link

Normally this won't happen as Sitecore does an excellent job of warning the author that they are breaking links. In this example I'll intentionally break a link to a test page. 

First, I create a content page with the following content:

The HTML for this field has the Guid to the destination item:

<a href="~/link.aspx?_id=E83A23F60B724F348DFDA48D5F28726B&_z=z">test page</a>

Next, I'll delete the item in that link. As it's a Guid, Sitecore knows a link is going to break, but I'm going ignore that:

The page will now have the following link after publishing:


The page now has this in the link on the published site. It doesn't know what the old URL was for this item since it's not there anymore to resolve the name, etc.  Like I said, the User is now faced with a page with many issues:

How to Make This Better

At the very least we can serve up a page with some type of branding and the context langue. Oh, I know, let's forward them to the standard 404 page! 

The following settings comes standard with Sitecore:

<setting name="ItemNotFoundUrl" value="/sitecore/service/notfound.aspx"/>
<setting name="LinkItemNotFoundUrl" value="/sitecore/service/notfound.aspx"/>

It's important to specify a non-language specific URL so the User isn't unexpectedly switched. You can enter the pre-authored page like I have here, or specify a page that really doesn't exist if you have some fancy processing going on and you want a custom 404 pipeline to run:

 <setting name="LinkItemNotFoundUrl" value="/404"/>
 <setting name="ItemNotFoundUrl" value="/404"/>

You will likely want to republish any pages that have the old links in them due to caching, though I personally found the correction to be immediate, but this setting change is only needed on the CD instance.