In this tutorial, you will learn some strategies to help you manage large volumes of page-types within Episerver CMS. If you are working on an Episerver project that has a lot of content, it is critical to get the content modelling right. Bad content modelling leads to three big issues, a frustrating content editing experience, poor performance and finally a potential need for developers to help make simple layout changes 🤔.In order for your site to work as efficiently as possible, how content is added within the page tree is important. In this guide, you will learn some tips to ensure you do not take a wrong path. Sounds good, read on 🔥🔥🔥
Hierarchy Is King
Episerver CMS is an enterprise-level solution that has been tested to work with huge amounts of content, however, you may find issues if you try and load several thousand-page types under a single node. On one project, I was asked to do an upgrade for a client. The site in question had a news section and the client released 5-10 news articles a week. No one had thought about a good page hierarchy so the news section had over 1000+ legacy stories. Content editors found the 'News' section a nightmare. They couldn't find content and it took a while for Episerver tree to load.
One way to prevent these types of content build-ups from occurring is to provide container page-types and make use of the
AvailableContentTypes attribute correctly. Using these two tools, it was easy to sort news articles by
Year and then have an alphabetical folder structure underneath it to allow content editors to easily find the articles they wanted. A container page type is just a default placeholder that has no content. If you use a container page type, remember that even though nothing may intentionally link to it directly, site visitors might be able to access them. It could pop up in breadcrumb and it will definitely appear in the page URL structure.
If you use a container page type, I recommend that you create a corresponding view for it. The only job of this view is to redirect a user to the parent node. This way if someone tries to view the page directly (say in a breadcrumb) they will not see a 404 page.
A container page is an extremely common CMS pattern. A container's job is to solely split the hierarchy into more manageable chunks, to make content editors live easier. When working with CMS 7 to create a container, you just define a page type as normal. Create a class, inherit from
PageData. The code for a container might look like this:
To make my code easier to manage, I also always decorate my container pages with an interface, like this:
Using an interface means you can have a single way to deal with all container pages 🔥🔥🔥. The quickest and safest is to create containers is to add this redirect in the associated controller. This means you need to create a controller for your container. This is done like this:
If you do not want to create a controller, another option is to define a custom MVC route to hide the container page. Setting up custom routing is a nicer way to solve the problem, however, it will take a lot more development work. One approach would be to create a
PartialRouter to intercept all page requests for a certain page type and then modify the outgoing Url to hide the containers segment from the Url. Even though it is possible I do not recommend modifying your website URL structure, as it usually creates more problems than it solves 😔
Today we've discussed the importance of managing your page hierarchy in order to design a system that has great performance and usability. Using a container page is one tool to help you in this quest, however, remember to think about how you will deal with the blank container page that will show in the Url. The quick and dirty way is to create a redirect that redirects a user to the container pages parent, this solves the issue as no one will ever be able to view the page. Happy Coding 🤘