For the complete documentation index, see llms.txt. This page is also available as Markdown.

Managing Views and Assets

How to manage templates, partial views, stylesheets, and JavaScript files, and what to consider when editing them in the backoffice.

Templates, partial views, stylesheets, and JavaScript files are all files in your Umbraco project. Templates and partial views are Razor views, and stylesheets and JavaScript files are static assets.

You can create and edit these files in the backoffice, which works well for quick changes during local development. For ongoing work, maintain them in an IDE and keep them in source control with the rest of your code. For more information, see Source Control.

Editing in the Backoffice

The backoffice works well for:

  • Generating a template alongside a new Document Type. For more information, see Working with Templates.

  • Creating a partial view from one of the built-in snippets. For more information, see Partial Views.

  • Making quick changes during local development.

For ongoing work, use an IDE. Keep the following limitations in mind:

  • The backoffice editors are plain text editors. They don't offer the tooling an IDE gives you, such as IntelliSense, linting, or formatting.

  • Depending on how you deploy, edits made in the backoffice of a deployed site might not move to your other environments. The next deployment can also overwrite them.

Templates and Partial Views

Templates and partial views contain C# code, but the backoffice editor doesn't warn you about errors in it. Nothing flags a mistyped property name or a missing using directive before you save. Mistakes only surface when the page renders.

The runtime mode of your site also affects backoffice editing:

  • In Production runtime mode, creating, editing, renaming, and deleting templates and partial views in the backoffice is blocked entirely. For more information, see Runtime Modes.

  • Outside Production, backoffice changes take effect immediately only in BackofficeDevelopment mode (the default) with the Umbraco.Cms.DevelopmentMode.Backoffice package installed. Otherwise, you must rebuild and restart the site. For details, see "InMemoryAuto models builder and Razor runtime compilation have moved into their own package" in the Version-specific upgrades guide.

Where the Files Live

File type
Default location

Templates

Views

Partial views

Views/Partials

Stylesheets

wwwroot/css

JavaScript files

wwwroot/scripts

Your site can serve stylesheets and JavaScript from anywhere under wwwroot, so these files don't have to sit in the default folders. The backoffice only lists the folders set by the UmbracoCssPath and UmbracoScriptsPath settings. For more information, see Global Settings.

Adding Files Outside the Backoffice

Stylesheets and JavaScript files in the folders set by UmbracoCssPath and UmbracoScriptsPath appear in the backoffice, even when you add or edit them elsewhere. Click ... next to the Stylesheets or Scripts folder and select Reload children to see the changes.

Templates work differently. Templates are registered in the Umbraco database, so a .cshtml file you add to the Views folder doesn't appear in the backoffice on its own. Create a template in the backoffice with an alias that matches the file name without the .cshtml extension. For example, a template with the alias homePage uses the Views/homePage.cshtml file. Umbraco keeps your existing file content instead of overwriting it. For more information, see Working with Templates.

Last updated

Was this helpful?