Skip to content
Menu
Search
Browse documentation & this page

Learning paths

Build with Razor

Create a typed page, render it with Razor, and publish it from the CMS.

Choose this path when your ASP.NET Core application will render the website. You own the HTML, CSS and JavaScript; Cendia supplies typed content, authoring and publication.

Before you begin

Use the .NET 10 SDK and SQL Server or LocalDB. Cendia comes from its own NuGet feed, https://nuget.cendia.com/index.json, which needs no key or sign-in. Install the starter template from it once; run the same command again to take a newer release's template.

Create your application:

dotnet new install Cendia.Templates --add-source https://nuget.cendia.com/index.json
dotnet new cendia-starter -n MySite
cd MySite
dotnet run

Open the address printed by the application. In Development, a local database receives the packaged CMS migrations at startup. A remote database requires a deliberate migration step; see Database changes. Configure credentials outside source control, for example with user secrets in development.

Checkpoint: /cms opens the first-account setup on a fresh local database. Complete it and sign in. An existing installation asks you to sign in instead. Managed hosting uses an issued setup link; see Hosting.

Define the content an author owns

Add a page type under Models/Pages. Keep the namespaces already used by the starter's models: Cendia.Schema for the type and attributes, and Cendia.FieldTypes for fields such as TextArea.

using Cendia.Schema;

[ContentTypeId("mysite.page.article")]
[ContentTypeDisplay("Article", "An authored article", "page")]
public sealed class Article : PageType
{
    [FieldId("mysite.article.heading")]
    [FieldDisplay("Heading", "Content", Order = 10)]
    [Required]
    public string? Heading { get; set; }
}

The heading belongs to the author. Spacing, typography, navigation and page structure belong to the template. Stable field and type IDs allow you to rename C# properties without renaming stored content. Do not change those IDs after content exists.

Checkpoint: build and restart the application; the CMS's New Page dialog offers Article. If it does not, check build errors and descriptor reconciliation before creating another type.

Render the page

Add Pages/Article.cshtml, following the starter's existing imports and page template pattern:

@model CmsPageModel<Article>

<article>
    <h1>@Model.Content.Heading</h1>
</article>

The class name pairs the page with its template. URLs come from the CMS tree, so this template does not need an @page route. Ensure Article is available through your _ViewImports.cshtml or use its fully qualified name.

Checkpoint: the project builds. Keep normal Razor escaping for plain strings.

Add reusable modules

When an author needs to compose sections, add a ContentZone to the page. Restrict it with AllowedContentTypes so the editor offers modules designed for this layout. Give each block a matching partial under Pages/Shared/Blocks and render the zone using @await Html.RenderZoneAsync(Model.Content.Sections).

Follow Templates and content zones for complete block and container examples. A block has its own publication lifecycle: placing a draft block on a page does not publish that block.

Create, preview and publish

In /cms, create an Article, fill in its heading and preview it. Publish it after validation passes. Configure its website's start page and hostname under Settings > Websites when it is the root of a new website. Enable Cendia:EnableRendering in the host configuration.

Checkpoint: open its public URL in a signed-out browser. The heading is rendered through your template. Change the heading in a draft and confirm that the public page still shows the published version until you publish again.

Ready to continue

  • Review Content types for media, links and editor controls.
  • Use Site search to expose published content to visitors.
  • Follow Hosting before deploying or promoting your application.
  • For an application that renders elsewhere, follow Build headless.