Create the layout file

To create layout files, perform the following:

  1. In Visual Studio, open your SitefinityWebApp project » ResourcePackages » [YourPackage].
    For more information, see Overview: Resource packages.

    NOTE: You can also create the layout file in the root folder of your project: ~/MVC/Views/Layouts. For more information, see Priorities for resolving views.

  2. Create new folder and name it Layouts.
  3. In the context menu folder Layouts, and click Add » Code File.
  4. Name the file in the same way that you named your page template.
    For example, if the page template is named mypagetemplate, you must name the layout file mypagetemplate.cshtml

    NOTE: The file extension of the layout file depends on the type of view engine you are using. For example, when using Razor view engine, you need to have a .cshtml layout file extension.

    NOTE: Replace all special characters in the file name with an underscore “_”.

  5. Open the layout file you created and paste the following markup:
  6. In the markup above, you specify the following layout file content:
    • using directive for Telerik.Sitefinity.frontend/Mvc/Helpers namespace
    • Document type tag <!DOCTYPE html>
    • <head> tag
    • <body> tag
    • Placeholders inside the <body> tag that you create by using a helper method @Html.SfPlaceHolder() that result in drop zones in the corresponding template in the Sitefinity CMS user interface
      The helper method accepts the name of the placeholder as an optional parameter.
  7. Save the file.

RESULT: After Sitefinity CMS restarts, it automatically creates a new page template with a name corresponding to the layout file you created. You can work with the page template straight away by navigating to Design » Page templates.

Want to learn more?

Sign up for our free beginner training. Boost your credentials through advanced courses and certification.
Register for Sitefinity training and certification.

Was this article helpful?