Layout and style

Overview


Next.js pages can use templates that are either stored in the Renderer application or created directly in the Sitefinity CMS backend based on the default template or other existing ones for the Next.js renderer.

  • Templates in the Renderer App: These are React functional components registered within the Renderer application. When a page is based on one of these templates, the Renderer uses it to display the page.
  • Templates in Sitefinity Backend: You can also create templates in the Sitefinity backend. These templates can be based on a default layout or a custom design and are stored in the Sitefinity database.
Out-of-the-box Sitefinity Next.js Renderer comes with a blank template called Default that you can select in the template selector. This template references Bootstrap5 CSS framework. The default Section widget also contain the Bootstrap5 grid system markup.

How to create custom template

This sample demonstrates how to setup a custom template component that can be used as a base for building your Next.js application. The template is meant to define what is in the body tags. You can refer scripts using the Next.js ccript element and its properties. In the case when you want to modify the whole page structure, you can do that by modifying or creating a global or a route-specific layout.tsx for more information, see Next.js documentation on Pages and layouts.

Template inheritance is available for custom templates as well. You can base your Sitefinity CMS templates on the custom templates from the Next.js Renderer.

To create your own custom template, you must do the following:

  1. Create a .tsx file that holds implementation of the template. The component accepts two arguments: widgets and requestContext.

  2. The widgets property is a dictionary of ReactNode components that are ready to be rendered. The key of the dictionary is the name of the container where the widgets should be placed. The requestContext property is of type RequestContext and holds information about the current request.
  3. To define your own custom sections, you can decorate several html tags (div, header, footer, aside, section, main, body) with the data-sfcontainer="your_placeholder_name" attribute, which will enable users to drop widgets into different placeholders.
  4. Register the custom template in the template registry, which is part of the starter project sample. That way the templates will be available in the backend UI of Sitefinity CMS and you can choose between them when you create new page. To do this go to Sitefinity backend » Pages » Create a page, enter page title and click Continue. Your template files will be available at the top of the template selector under the section Next.js templates:

Want to learn more?

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

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. 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?