One of the new features in Orchard 1.4 is Autoroute, which like most features, arrives in the form of an Orchard Module. Autoroute is a new Content Part that attaches to Content Types and replaces the Route Part to offer much more flexibility in routing patterns for routable content types. Autoroute provides the ability to create and select custom route patterns, override patterns on a case by case basis, and the ability to regenerate the route when new versions of the content item are saved. In addition to specifying static values in the routes, Autoroute also leverages tokens in Orchard that allow you to create routes based on dynamic information such as creation date, user, and other information that may vary from content item to content item.

Goodbye to Route Part in Orchard CMS

With the release of Orchard 1.4 we can say goodbye to the Route Part. The Route Part actually had a tough life as it was pulling double-duty for routable content types. It was both handling the title of the Content Type as well as the routable slug. Just after you typed in a title for a page or blog post, for example, it was the Route Part that generated a unique slug for that content item based on the title. Since it only generated the slug based on the title it wasn't possible to generate slugs based on more custom patterns and dynamic information like creation date, user, etc. The Route Part also had this nasty side-effect that caused a Publish Event to fire whenever it obtained a new slug for the content item, causing the Rules Engine in Orchard to be of very little use when dealing with the publishing of content types. Autoroute fixes these limitation and problems, which is a great thing!

Route Part in Orchard CMS

Autoroute and Title Content Parts in Orchard CMS

In Orchard 1.4 you will now see the Route Content Part replaced by the Autoroute and Title Parts. The Autoroute Part will handle the route generation needs for the content item and the Title Part will handle the Title needs. Hence, in Orchard 1.4 you will see the Autoroute and Title Parts attached to a content type as opposed to the Route Part.

Autoroute and Title Parts in Orchard CMS

Autoroute Settings in Orchard

Whereas the Route Part in Orchard had no settings, the Autoroute Part has essentially 3 settings.

  • Allow Custom Patterns - Selecting this option allows the contributor creating the content item to specify or override the creation of the route / slug when creating the content item. The contributor can then specify a pattern different than the default pattern for the content type.
  • Automatically regenerate when editing content - Selecting this option means the route can change whenever a contributor changes the content item. If, for example, the route pattern is based on the title and the contributor changes the title when editing it, the route of the content item will change when saved. Typically this may not be a good selection for SEO purposes as you usually want the route to stay the same once it is published on the website.
  • Specifying Default and Custom Patterns - Autoroute provides a table of default and custom patterns that allow the Orchard Developer to specify how the route for the content type should be generated based on static information as well as tokens.

An example of these settings are shown below for a Blog Post.

Autoroute Blog Post in Orchard CMS

Three things you will notice.

  • The blog post creator does have the ability to override the default route pattern, called Blog and Title, when creating a new blog post because the Allow custom patterns option is selected.
  • Once the route is generated for the first time it is never re-generated by Autoroute since the Automatically regenerate when editing content option has not been selected.
  • The default pattern for a blog post route is based on two tokens - the path of the container and the slug generated from the title of the blog post. This is essentially what we have today using the Route Part.

If you have the proper authorization, you can change these settings by editing the Autoroute Part of the Blog Post Content Type.

Specifying Custom Autoroute Patterns for Orchard Blog Post

If you don't like the default Autoroute Pattern for a blog post, change it. Let's go token crazy and specify a new route based on the Blog, Date Created, and Title of the blog post in Orchard. Here is the new pattern for the blog post route.


You probably recognize this old school blog post pattern as it will generate a route like this:


Specify this as the default pattern for each blog post.

Specify Custom Autoroute Patterns for Blog Post in Orchard CMS

When the blog post contributor goes to create a new blog post they are able to see the default pattern as a hint, but also have the ability to override it since I left the Allow custom patterns option selected.

New Blog Post with Custom Autoroute Route in Orchard CMS

One thing you should note is that when the Allow custom patterns in the Autoroute Settings is not selected, there is no textbox allowing the contributor to type in a custom route. The Orchard Blog Post Route will only be generated by Autoroute.

When I type in a new title for this Blog Post and save it, Autoroute will generate a new route based on my default pattern.

Save Orchard Blog Post with Autoroute

Autoroute Option - Automatically Regenerate Route When Editing Content

One of the Autoroute Settings mentioned earlier is the ability for Autoroute to regenerate the route after a user edits the content item. This is an interesting option as that it is probably a neat idea before an item is published for the first time, but perhaps not so good for SEO once an item has been published. Having the route change for an item that has already been indexed in various search engines and linked by 3rd parties is not the best of ideas, but I am sure there are reasons for it beyond SEO.

Let's say we have saved a blog post using the custom Autoroute pattern for Orchard Blog Posts mentioned earlier. This pattern is based on the blog post's title, which in this case was called Original Title ( catchy I know ). I originally created this blog post on February 23, 2012 with a title of Original Title and you can see the current route as blog/02/23/2012/original-title.

I am making a change to the title of this blog post and calling it, Route Will Change With New Title.

Autoroute will Regenerate New Route for Orchard Blog Post in Orchard CMS

If I have selected the Autoroute option to automatically regenerate when editing content for blog posts, once I re-save the blog post the route for this blog post will be regenerated based on the new blog post title which is part of the default routing pattern. Now that I have changed the title and saved it, notice the new permalink for the Orchard Blog Post.

New Autoroute Route Regenerated for Orchard Blog Post in Orchard CMS


The new Autoroute Part in Orchard 1.4 is a great new content part and along with the Title Part replaces the Route Part in Orchard. It not only offers the ability to allow custom patterns and regenerate routes after editing a content item, but it also provides a feature rich pattern mechanism based on additional tokens other then the content item's title. Orchard administrators have the ability to modify Autoroute Settings as well as specify new and default patterns for route generation. Along with the new Alias Feature, which I will talk about in a future post, routable content types in Orchard just got a whole lot more interesting.

Check out my other Orchard Tutorials.