umbraco-routing by umbraco/umbraco-cms-backoffice-skills
npx skills add https://github.com/umbraco/umbraco-cms-backoffice-skills --skill umbraco-routingUmbraco 后台的路由功能支持使用基于路径名的 URL 在功能区、仪表板和编辑器之间进行导航。功能区作为主要的组织划分单元,可以通过功能区视图、仪表板或自定义元素作为入口点。自定义路由可以使用 umb-router-slot 构建,其路由定义支持参数和重定向。
在实现之前,请务必获取最新的文档:
Umbraco 源代码中包含一个可运行的示例:
位置 : /Umbraco-CMS/src/Umbraco.Web.UI.Client/examples/modal-routed/
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
此示例演示了支持基于 URL 导航和深度链接的路由模态框。请研究此示例以了解复杂路由模式。
{
"type": "section",
"alias": "My.Section",
"name": "My Section",
"meta": {
"label": "My Section",
"pathname": "my-section"
}
}
URL: /section/my-section
{
"type": "dashboard",
"alias": "My.Dashboard",
"name": "My Dashboard",
"meta": {
"label": "Welcome",
"pathname": "welcome-dashboard"
},
"conditions": [
{
"alias": "Umb.Condition.SectionAlias",
"match": "Umb.Section.Content"
}
]
}
URL: /section/content/dashboard/welcome-dashboard
import { html, customElement, state } from '@umbraco-cms/backoffice/external/lit';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import type { UmbRoute } from '@umbraco-cms/backoffice/router';
@customElement('my-routed-element')
export class MyRoutedElement extends UmbLitElement {
@state()
private _routes: UmbRoute[] = [
{
path: 'person/:personId',
component: () => import('./person.element.js'),
setup: (_component, info) => {
console.log('personId:', info.match.params.personId);
},
},
{
path: 'people',
component: () => import('./people.element.js'),
},
{
path: '',
redirectTo: 'people',
},
];
render() {
return html`
<umb-router-slot .routes=${this._routes}></umb-router-slot>
`;
}
}
{
path: 'edit/:id',
component: () => import('./edit.element.js'),
setup: (component, info) => {
const id = info.match.params.id;
component.itemId = id;
},
}
{
path: '',
redirectTo: 'overview',
}
@state()
private _routes: UmbRoute[] = [
{
path: 'overview',
component: () => import('./overview.element.js'),
},
{
path: 'settings',
component: () => import('./settings.element.js'),
},
{
path: 'item/:id',
component: () => import('./item-detail.element.js'),
setup: (component, info) => {
component.itemId = info.match.params.id;
},
},
{
path: '',
redirectTo: 'overview',
},
];
render() {
return html`
<nav>
<a href="/section/my-section/overview">Overview</a>
<a href="/section/my-section/settings">Settings</a>
<a href="/section/my-section/item/123">Item 123</a>
</nav>
<umb-router-slot .routes=${this._routes}></umb-router-slot>
`;
}
{
"type": "sectionView",
"alias": "My.SectionView",
"name": "My Section View",
"element": "/App_Plugins/MyExtension/section-view.js",
"meta": {
"label": "Organization",
"pathname": "organization",
"icon": "icon-users"
},
"conditions": [
{
"alias": "Umb.Condition.SectionAlias",
"match": "My.Section"
}
]
}
URL: /section/my-section/organization
// Parent element
@state()
private _routes: UmbRoute[] = [
{
path: 'admin',
component: () => import('./admin-layout.element.js'),
},
{
path: 'users',
component: () => import('./users-layout.element.js'),
},
];
// Admin layout element can have its own nested routes
@state()
private _adminRoutes: UmbRoute[] = [
{
path: 'dashboard',
component: () => import('./admin-dashboard.element.js'),
},
{
path: 'settings',
component: () => import('./admin-settings.element.js'),
},
];
{
path: 'edit/:documentId',
component: () => import('./document-editor.element.js'),
setup: (component, info) => {
// Access route parameters
const documentId = info.match.params.documentId;
// Pass to component
component.documentId = documentId;
// Can also access query params, etc.
console.log('Route info:', info);
},
}
pathname : 功能区/仪表板/视图的 URL 片段
umb-router-slot : 渲染匹配路由的组件
UmbRoute : 包含路径、组件、设置的路由定义
路由顺序 : 首次匹配优先 - 顺序很重要!
参数 : 在路径中使用 :参数名(例如 item/:id)
重定向 : 使用 redirectTo 重定向到另一个路径
setup 函数 : 在路由匹配时调用,接收组件和路由信息
URL 结构 :
/section/my-section/section/content/dashboard/welcome/section/my-section/organization/section/my-section/people/person/123入口点 :
就是这样!请务必获取最新的文档,保持示例简洁,生成完整可运行的代码。
每周安装量
73
代码仓库
GitHub 星标数
14
首次出现
2026年2月4日
安全审计
安装于
github-copilot54
cursor26
opencode25
codex25
gemini-cli23
amp23
Routing in Umbraco's backoffice enables navigation between sections, dashboards, and workspaces using pathname-based URLs. Sections serve as primary organizational dividers with entry points via section views, dashboards, or custom elements. Custom routing can be built using umb-router-slot with route definitions that support parameters and redirects.
Always fetch the latest docs before implementing:
The Umbraco source includes a working example:
Location : /Umbraco-CMS/src/Umbraco.Web.UI.Client/examples/modal-routed/
This example demonstrates routed modals with URL-based navigation and deep-linking support. Study this for complex routing patterns.
{
"type": "section",
"alias": "My.Section",
"name": "My Section",
"meta": {
"label": "My Section",
"pathname": "my-section"
}
}
URL: /section/my-section
{
"type": "dashboard",
"alias": "My.Dashboard",
"name": "My Dashboard",
"meta": {
"label": "Welcome",
"pathname": "welcome-dashboard"
},
"conditions": [
{
"alias": "Umb.Condition.SectionAlias",
"match": "Umb.Section.Content"
}
]
}
URL: /section/content/dashboard/welcome-dashboard
import { html, customElement, state } from '@umbraco-cms/backoffice/external/lit';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import type { UmbRoute } from '@umbraco-cms/backoffice/router';
@customElement('my-routed-element')
export class MyRoutedElement extends UmbLitElement {
@state()
private _routes: UmbRoute[] = [
{
path: 'person/:personId',
component: () => import('./person.element.js'),
setup: (_component, info) => {
console.log('personId:', info.match.params.personId);
},
},
{
path: 'people',
component: () => import('./people.element.js'),
},
{
path: '',
redirectTo: 'people',
},
];
render() {
return html`
<umb-router-slot .routes=${this._routes}></umb-router-slot>
`;
}
}
{
path: 'edit/:id',
component: () => import('./edit.element.js'),
setup: (component, info) => {
const id = info.match.params.id;
component.itemId = id;
},
}
{
path: '',
redirectTo: 'overview',
}
@state()
private _routes: UmbRoute[] = [
{
path: 'overview',
component: () => import('./overview.element.js'),
},
{
path: 'settings',
component: () => import('./settings.element.js'),
},
{
path: 'item/:id',
component: () => import('./item-detail.element.js'),
setup: (component, info) => {
component.itemId = info.match.params.id;
},
},
{
path: '',
redirectTo: 'overview',
},
];
render() {
return html`
<nav>
<a href="/section/my-section/overview">Overview</a>
<a href="/section/my-section/settings">Settings</a>
<a href="/section/my-section/item/123">Item 123</a>
</nav>
<umb-router-slot .routes=${this._routes}></umb-router-slot>
`;
}
{
"type": "sectionView",
"alias": "My.SectionView",
"name": "My Section View",
"element": "/App_Plugins/MyExtension/section-view.js",
"meta": {
"label": "Organization",
"pathname": "organization",
"icon": "icon-users"
},
"conditions": [
{
"alias": "Umb.Condition.SectionAlias",
"match": "My.Section"
}
]
}
URL: /section/my-section/organization
// Parent element
@state()
private _routes: UmbRoute[] = [
{
path: 'admin',
component: () => import('./admin-layout.element.js'),
},
{
path: 'users',
component: () => import('./users-layout.element.js'),
},
];
// Admin layout element can have its own nested routes
@state()
private _adminRoutes: UmbRoute[] = [
{
path: 'dashboard',
component: () => import('./admin-dashboard.element.js'),
},
{
path: 'settings',
component: () => import('./admin-settings.element.js'),
},
];
{
path: 'edit/:documentId',
component: () => import('./document-editor.element.js'),
setup: (component, info) => {
// Access route parameters
const documentId = info.match.params.documentId;
// Pass to component
component.documentId = documentId;
// Can also access query params, etc.
console.log('Route info:', info);
},
}
pathname : URL segment for sections/dashboards/views
umb-router-slot : Component that renders matched route
UmbRoute : Route definition with path, component, setup
Route Order : First match wins - order matters!
Parameters : Use :paramName in path (e.g., item/:id)
Redirects : Use redirectTo to redirect to another path
setup Function : Called when route matches, receives component and route info
URL Structure :
/section/my-section/section/content/dashboard/welcome/section/my-section/organization/section/my-section/people/person/123Entry Points :
That's it! Always fetch fresh docs, keep examples minimal, generate complete working code.
Weekly Installs
73
Repository
GitHub Stars
14
First Seen
Feb 4, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
github-copilot54
cursor26
opencode25
codex25
gemini-cli23
amp23
Genkit JS 开发指南:AI 应用构建、错误排查与最佳实践
7,700 周安装
Claude技能创建指南:高效开发AI代理技能,扩展Claude能力
200 周安装
Home Assistant 集成与附加组件管理工具 - 自动化配置与安全更新
206 周安装
MyBatis-Plus代码生成器使用指南 - 快速生成Entity、Service、Controller代码
204 周安装
飞书云文档创建工具 - 通过MCP调用feishu-create-doc从Markdown创建文档
211 周安装
技术债务评估工具 - 系统化识别、量化与管理代码质量债务,优化开发决策
204 周安装
中国A股实时股票价格查询工具 - Python脚本,支持多股查询与默认指数
208 周安装