Enable content tree-based routing

Before you can start using content tree-based routing, the related feature needs to be enabled in the Xperience .NET application.

  1. Open your project in Visual Studio and edit the Program.cs file.

  2. Enable the content tree-based routing feature by calling UseWebPageRouting within AddKentico.

    Program.cs
    
    
    using Kentico.Content.Web.Mvc.Routing;
    using Kentico.Web.Mvc;
    
    ...
    
    WebApplicationBuilder builder = WebApplication.CreateBuilder(args);
    
    ...
    
    builder.Services.AddKentico(features =>
    {
        // Enables content tree-based routing
        features.UseWebPageRouting();
    });
    
    

Content tree-based routing is now enabled for the application. The Kentico().MapRoutes()method called in your application’s startup pipeline registers a general route that matches URLs generated by the system for content types with the Include in routing option set.

Optional routing configuration

  1. Edit your website channel in the Channel management application and switch to Channel settings.
  2. Under the Content tree-based routing section:
    • Enter the tree path of your desired home page into the Home page field.

      • To find the Tree path of a page, open the website channel’s application, select the page, and go to Properties → Information.
      • The system displays the specified page when the root URL is accessed.
      • Using a unified home page URL is highly recommended because it prevents the duplicate content problem on your website’s most important URL.
    • Enable the Store former URLs setting if you want the system to keep track of changes made to page URLs and perform redirects from former to current URLs.

      • To prevent the accumulation of various temporary URLs as former URLs, we recommend enabling this setting only on live websites (i.e. production environments).
  3. Save the changes.