---
title: Web templates
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

List of examples:

### Creating a web template

```csharp

// Creates a new web template object
WebTemplateInfo newTemplate = new WebTemplateInfo();

// Sets the web template properties
newTemplate.WebTemplateDisplayName = "New site template";
newTemplate.WebTemplateName = "NewSiteTemplate";
newTemplate.WebTemplateDescription = "This is web template created through the Kentico API.";
newTemplate.WebTemplateFileName = "~\\App_Data\\Templates\\NewSiteTemplate";
newTemplate.WebTemplateLicenses = "X";

// Sets the web template order (places the new web template at the end of the list of all templates)
InfoDataSet<WebTemplateInfo> webTemplates = WebTemplateInfoProvider.GetWebTemplates(null, null, 0, "WebTemplateID", false);
newTemplate.WebTemplateOrder = webTemplates.Items.Count + 1;            

// Saves the web template to the database
WebTemplateInfoProvider.SetWebTemplateInfo(newTemplate);

```

[> Back to list of examples](#webtemplates-toc)

### Updating a web template

```csharp

// Gets the web template
WebTemplateInfo updateTemplate = WebTemplateInfoProvider.GetWebTemplateInfo("NewSiteTemplate");
if (updateTemplate != null)
{
    // Updates the web template properties
    updateTemplate.WebTemplateDisplayName = updateTemplate.WebTemplateDisplayName.ToLower();

    // Moves the template down in the list of all templates
    WebTemplateInfoProvider.MoveTemplateDown(updateTemplate.WebTemplateId);

    // Moves the template up in the list of all templates
    WebTemplateInfoProvider.MoveTemplateUp(updateTemplate.WebTemplateId);

    // Saves the template changes to the database
    WebTemplateInfoProvider.SetWebTemplateInfo(updateTemplate);
}

```

[> Back to list of examples](#webtemplates-toc)

### Updating multiple web templates

```csharp

// Prepares a where condition for loading all web templates whose name starts with 'New'
string where = "WebTemplateName LIKE N'New%'";

// Gets all web templates that fulfill the condition
InfoDataSet<WebTemplateInfo> templates = WebTemplateInfoProvider.GetWebTemplates(where, null);

// Loops through individual web templates
foreach (WebTemplateInfo template in templates)
{
    // Updates the template properties
    template.WebTemplateDisplayName = template.WebTemplateDisplayName.ToUpper();

    // Saves the changes to the database
    WebTemplateInfoProvider.SetWebTemplateInfo(template);
}

```

[> Back to list of examples](#webtemplates-toc)

### Deleting a web template

```csharp

// Gets the web template
WebTemplateInfo deleteTemplate = WebTemplateInfoProvider.GetWebTemplateInfo("NewSiteTemplate");

if (deleteTemplate != null)
{
    // Deletes the web template
    WebTemplateInfoProvider.DeleteWebTemplateInfo(deleteTemplate);
}

```

[> Back to list of examples](#webtemplates-toc)
