HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityDoc feedbackLog In
GitHubNuGetDev CommunityDoc feedback


## MenuItem attribute

Use `MenuItem` on MVC controllers. `MenuItem` adds links to the top menu (and requires the module to be registered; see [Configuring Shell modules](🔗). The required `menuPath` parameter is a logical path of the menu element in the menu. The `Url` parameter can optionally be added to specify the linked URL to the interface. By default is the URL set to the registered shell route for the module (_'/EPiServer/{ShellModule}/{controller}/{action}'_ for protected modules and '_/modules/{ShellModule}/{controller}/{action}'_ for public modules).

The following example adds a menu item to the top menu bar with the text **Start** and the URL is inferred from the registered route for the shell module:



When you have added menu items, you need to implement the new page to include Optimizely Content Management System (CMS) styling for shell and also render the menu so you can navigate back.

The key function to render a menu is `@Html.CreatePlatformNavigationMenu()`.

Note that the calls to `Html.ShellInitializationScript()` might still be needed depending on what content you are showing in addition to the navigation menu. It is not necessary for the navigation menu itself.

In addition to `Html.CreatePlatformNavigationMenu`, you also need to wrap content below the menu in an element decorated by using this html helper `html.ApplyPlatformNavigation()`.

Note

The Platform Navigation font sizing uses REM and expects the root element to have size 16px (browser default). Some style frameworks, such as Bootstrap 3, override the root font size while others, like Bootstrap 4, do not.

To adapt the example above to work with versions 11.21 and higher, you need to start using `CreatePlatformNavigationMenu()` and `ApplyPlatformNavigation()`. Note that you no longer need `@Html.Raw(ClientResources.RenderResources("Navigation"))` nor `@Html.Raw(Html.ShellInitializationScript())`:



### Localize menu items with the MenuItem attribute

You can localize menu items by specifying `TextResourceKey`. By default is the key resolved against `LocalizationService`. Alternatively attribute `ResourceType` can be specified that then should be a class with a with a static property named `TextResourceKey` that returns the localized text.

Example:



### Organize menu items

The menu path is used to organize menu items in a tree structure. All menu items in the top menu are in the /global bucket. The next segment is the name of menu section, for example, /global/cms. The last segment represents the actual user interface, for example, /global/cms/edit.

### Permissions with the MenuItem attribute

By default is an security policy applied to controllers for a shell module. The policy to use can be configured through attribute _'\_authorizationPolicy_'\_in [module.config](🔗). The availability for the menu item will then be evaluated through the policy. It is possible to apply the [AuthorizeAttribute](🔗) to specify a custom authorization to complement the default policy that applies to the module. Note however that if there is a policy for the shell module, then that policy will also be evaluated for the request.



## Examples

### Global menu button

277



### Extend the CMS menu section.





### Add a second level menu.



In the example below, a second level menu is added to the existing "Admin" menu.



### New global menu section



While the example below works, you should not use the main navigation for external links. A better example for external links could be example 6 below.



### Extend the User Settings menu using controller action.





### Extend the User Settings menu using menu provider.





### New drop-down menu with items