Create MVC page templates based on layout files

Say you created a layout file, according to the naming conventions for Sitefinity CMS MVC development and place it in a specific folder in the file system. You can now use your layout file to base page templates on. Or, say your layout file was located in a location, different than your Bootstrap 4 resource package folder. You want to place the layout file in its recommended location.

NOTE: Keep in mind that this is a corner case that you will not usually encounter when following the general workflow of working with page templates. 

After you place your layout file in a project folder of your choice (in the root of the project or in the Resource packages folder), in Sitefinity CMS backend, you need to create an MVC page template that is associated with the layout file. Thus, you can work with and modify the template and use it in pages. When you base a page template on a layout file you created, you have full control over the file and can directly edit it from Sitefinity CMS backend. You can also add widgets to the template.

The following table summarizes how to base a page template on a layout file, depending on where the file is located.

Layout file location

Page template mapping

mvc/views/layouts/ folder

(does not belong to any package)

Navigate to Design»Page templates and create an MVC only template with a name that corresponds to the name of the layout file on the file system.
For example, if you want to use the Main.cshtml file, located in the mvc/views/layouts/ folder, navigate to Design » Page templates and create an MVC only template with name and developer name Main.

resourcepackages/bootstrap5/mvc/views/layouts/ folder

Navigate to Design » Page templates and create an MVC only template with a name that abides by the naming convention [resource-package-name].[file-name]. For more information, see Naming conventions.
For example, if you want to use the Main.cshtml file, located in the resourcepackages/bootstrap5/mvc/views/layouts/ folder, navigate to Design » Page templates and create an MVC only template with name and developer name Bootstrap5.Main.

This mapping works the other way around as well. For example, if you have page templates in Sitefinity CMS that are not based on layout files on the file system, you can create the layout files following the naming convention and they are automatically mapped. For more information, see Base MVC page templates on layout files.

 

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Web Security for Sitefinity Administrators

The free standalone Web Security lesson teaches administrators how to protect your websites and Sitefinity instance from external threats. Learn to configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?