---
title: Rendering widgets in code
related:
  - https://docs.kentico.com/13/developing-websites/page-builder-development.md
  - https://docs.kentico.com/13/developing-websites/page-builder-development/developing-widgets.md
  - https://docs.kentico.com/13/developing-websites/page-builder-development/developing-widgets/defining-widget-properties.md
---

> 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).

Developers can display [page builder widgets](https://docs.kentico.com/13/developing-websites/page-builder-development/developing-widgets.md) manually, without the need to set up [editable regions](https://docs.kentico.com/13/developing-websites/page-builder-development/creating-pages-with-editable-areas.md) and insert widgets in the page builder interface. The API allows widgets to be rendered directly in the code of MVC views. These can be views that define the output of standard pages and layouts, or even other page builder components, such as [page templates](https://docs.kentico.com/13/developing-websites/page-builder-development/developing-page-templates.md) or [sections](https://docs.kentico.com/13/developing-websites/page-builder-development/developing-page-builder-sections.md).

For example, this rendering approach can be used to include a widget into a site's main layout (the website header or footer). The widget appears as a fixed part of the website, and cannot be removed or adjusted by content editors.

## Requirements

- The page builder feature must be enabled for your MVC project, as described in [Page builder development](https://docs.kentico.com/13/developing-websites/page-builder-development.md) (even though the widgets are rendered without the page builder interface).
- To allow direct rendering, widgets must be registered using the _RegisterWidget_ assembly attribute (as described in [Developing widgets](https://docs.kentico.com/13/developing-websites/page-builder-development/developing-widgets.md)).
- The page where the widget is rendered must include links to [page builder scripts and styles](https://docs.kentico.com/13/developing-websites/page-builder-development/creating-pages-with-editable-areas.md#loading-page-builder-scripts-and-styles), if these are required by the given widget. The [system's default widgets](https://docs.kentico.com/13/developing-websites/page-builder-development/reference-system-widgets.md) require the page builder scripts and styles.

## Rendering widgets

<!-- dev-model:mvc start -->

**MVC 5 development model.** Applies only when building with ASP.NET MVC 5. If this page also covers ASP.NET Core, that version is in its own block.

Edit the code of the view where you want to display the widget and call the **Html.Kentico().RenderStandaloneWidget** extension method (available in the _Kentico.PageBuilder.Web.Mvc_ namespace).

Specify the following parameters for the method:

- **identifier** – the _string_ identifier under which the widget was registered. For identifiers of the default system widgets, check [the system widget reference](https://docs.kentico.com/13/developing-websites/page-builder-development/reference-system-widgets.md).
- **properties** – _IWidgetProperties_ object representing the widget's [properties](https://docs.kentico.com/13/developing-websites/page-builder-development/developing-widgets/defining-widget-properties.md). Create an instance of the appropriate property model class and set any required values. Currently, the properties parameter is required and you cannot render widgets without properties. As a workaround, you can create and register an empty property model for the widget.

```xml

@using Kentico.PageBuilder.Web.Mvc
@using Kentico.Content.Web.Mvc
@using Kentico.Web.Mvc

...

@{
    // Prepares properties for the Form widget
    var widgetProperties = new FormWidgetProperties()
    {
        SelectedForm = "FormCodeName"
    };
}

@* Renders the Form widget *@
@Html.Kentico().RenderStandaloneWidget(SystemComponentIdentifiers.FORM_WIDGET_IDENTIFIER, widgetProperties); 

```

> **Info:** **Note**: Do not use the _RenderStandaloneWidget_ method in the views of other widgets. If you are developing a widget that extends the HTML output or functionality of an existing widget, call the **RenderNestedWidget** extension method instead. For more information, see [Extending widgets](https://docs.kentico.com/13/developing-websites/page-builder-development/developing-widgets/extending-widgets.md).

<!-- dev-model:mvc end -->

<!-- dev-model:core start -->

**ASP.NET Core development model.** Applies only when building with ASP.NET Core. If this page also covers MVC 5, that version is in its own block.

Edit the code of the view where you want to display the widget and call the **Html.Kentico().RenderStandaloneWidget** extension method (or its [Tag Helper](https://docs.kentico.com/13/developing-websites/developing-xperience-applications-using-asp-net-core/reference-xperience-tag-helpers.md) equivalent).

Specify the following parameters for the method:

- **identifier** – the _string_ identifier under which the widget was registered. For identifiers of the default system widgets, check [the system widget reference](https://docs.kentico.com/13/developing-websites/page-builder-development/reference-system-widgets.md).
- **properties** – _IWidgetProperties_ object representing the widget's [properties](https://docs.kentico.com/13/developing-websites/page-builder-development/developing-widgets/defining-widget-properties.md). Create an instance of the appropriate property model class and set any required values. Currently, the properties parameter is required and you cannot render widgets without properties. As a workaround, you can create and register an empty property model for the widget.

```csharp

@using Kentico.PageBuilder.Web.Mvc
@using Kentico.Content.Web.Mvc
@using Kentico.Web.Mvc

...

@{
    // Prepares properties for the Form widget
    var widgetProperties = new FormWidgetProperties()
    {
        SelectedForm = "FormCodeName"
    };    
}

@* Renders the Form widget *@
@await Html.Kentico().RenderStandaloneWidget(SystemComponentIdentifiers.FORM_WIDGET_IDENTIFIER, widgetProperties); 

```

> **Info:** **Note**: Do not use the _RenderStandaloneWidget_ method in the views of other widgets. If you are developing a widget that extends the HTML output or functionality of an existing widget, call the **RenderNestedWidget** extension method instead. For more information, see [Extending widgets](https://docs.kentico.com/13/developing-websites/page-builder-development/developing-widgets/extending-widgets.md).

<!-- dev-model:core end -->
