In this tutorial, you will learn how to restrict the page types that can be created under the root node within an Episerver CMS powered website. In order to make content editors' lives a lot easier, it's a good idea to restrict what page types they can create and where they can create them. In Episerver this is possible by using the [AvailableContentType] attribute on top of any page type definition. For example, if you added the following code then content editors would only be allowed to create a child page that was of type StartPage:

In every Episerver website, the top-level item in the page tree starts from a node known as the Root node:

Restricting The Episerver Page Types That Can Be Created Under The Root Page

As the root page is a default system type, you cant create a custom page-type definition for it. This means you can't apply the [AvailableContentType] attribute to it. By default, content editors can create any page type they want under Root, not ideal. Luckily there is a way to override the default root page behaviour by creating a page type called SysRoot. Create a class called SysRoot and inherit from PageData. In it, you inject your own property into the system root. The code to do this looks like this:

That's it.. we have now restricted what page types can be created under Root. By creating a page called sysroot that inherits from PageData you apply your own rules. Happy Coding 🤘