Content tree-based routing

With content tree-based routing, the system generates and matches page URLs based on their position in the website’s content tree. You don’t need to perform any manual route mapping and configuration. All routing logic is handled for you by the system. 

This method of routing is not a full replacement of the standard ASP.NET routing model. Instead, it augments the routing pipeline, handling requests targeting the site’s pages. You can still set up additional routes for your application.

This simplified diagram models request handling when using content tree-based routing:

Request handling in the content tree-based routing mode

Incoming requests are matched against a general route and their target URL compared to system URLs and vanity URLs of existing pages. If there is a match with a route in the system (system or vanity URL), the system takes over the routing logic. Otherwise, the request continues matching against routes registered further down the routing table using conventional ASP.NET routing.

Once the request is taken over by Xperience, all routing happens automatically. You need to supply a controller, view model and view for each content type to provide the desired processing logic and output formatting.

Page URL generation

The system automatically generates URLs only for pages that have the Include in routing option set in their content type definition.

A page system URL is generated when:

  • a new page is created
  • the URL slug of an existing page is updated

The overall system URL is determined by the page’s location in the site’s content tree:

  • The system takes all of the page’s ancestors up to the site’s root (‘/’):
    • If an ancestor has the Include in routing option set for its content type, it contributes a segment to the page’s resulting URL. All other ancestors are skipped.
    • By default, the segment is formed from the page’s title converted to a URL-sanitized string.

The following diagram illustrates how URLs are generated based on a page’s position in the content tree and the configuration of its ancestors:

Automatic URL generation illustrated

The Articles section holds a collection of articles (Article 1 and Article 2). All pages are based on content types that have the Include in routing option set. As a result, both articles also contain their parent page segment (Articles) in their URL.

The Landing pages section holds a collection of landing pages (Page 1 and Page 2). Only the landing pages are based on a content type with the Include in routing option set. As a result, the URLs of both landing pages do not include their parent.

Multilingual URLs

If you have multiple languages set up in your project, the settings of individual languages affect system URL generation in the following way:

  • For pages that are in the primary language of a website channel, URLs are not modified.
    • For example, if English is set as the primary language of the website channel, the URLs of pages in English will be in the ~/page format.
  • For pages in a non-primary language, the language’s Code name is inserted into the URL path after the site’s root (‘/’).
    • For example, if English is set as the primary language of the website channel, the URLs of pages in Spanish will be in the ~/es/page format.
    • Vanity URLs of pages in a non-primary language DO NOT include the language’s Code name.
  • Vanity URLs and the Make vanity URL canonical setting are completely separate for each language.
    • Regardless of the primary language of the website channel, the vanity URLs of pages in Spanish will be in the ~/spanishVanityPath format and in English it will be in the ~/englishVanityPath format.

Handling of unpublished pages

Once a system URL is generated for a page, it persists until the corresponding page is deleted. This includes cases when the page is unpublished.

If a request targets such a page, the system responds with the HTTP 404 (Not Found) status and the request does not continue matching against other routes. This is to prevent accidentally matching requests intended to be handled by Xperience against other loosely constrained routes registered further down the routing table. You can use conventional 404 error handling for such cases.

Configure your project to use content tree-based routing

 To start using content tree-based routing in your project:

  1. Enable content tree-based routing.
  2. Set up the routing environment.