主题布局选项
大约 5 分钟
以下选项控制主题布局。
导航栏相关
NavbarLayoutOptions默认值
{ start: ["Brand"], center: ["Links"], end: ["Language", "Repo", "Outlook", "Search"] }自定义导航栏布局。
参考:布局 → 导航栏 → 导航栏布局。
每个字段接受一组内置导航栏组件名称或自定义组件名称:
type NavbarComponent =
"Brand" | "Links" | "Language" | "Search" | "Outlook" | "Repo";(NavbarComponent | string)[]导航栏开头的组件。
(NavbarComponent | string)[]导航栏中间的组件。
(NavbarComponent | string)[]导航栏结尾的组件。
logorecommended: Yes
string导航栏图标,应为基于 .vuepress/public 文件夹的绝对路径。
参考:布局 → 导航栏 → 站点图标。
string默认值
$siteLocale.title导航栏标题,你可以设置为 '' 来隐藏它。
repo
string仓库配置,用于在导航栏中显示仓库链接。
repoLabel
string'always' | 'mobile' | 'none'默认值
'mobile'是否在向下滚动时自动隐藏导航栏。
hideSiteNameOnMobile
boolean默认值
true是否在移动视图下隐藏站点名称。
侧边栏相关
关于配置指南,详见 布局 → 侧边栏。
sidebarrecommended: Yes
SidebarOptions默认值
'structure'侧边栏配置。
sidebarSorterroot-only: Yes
SidebarSorter默认值
["readme", "order", "title", "filename"]结构侧边栏排序器。
你可以:
- 填写自定义函数
- 提供一个排序器关键字
- 提供一组自定义函数或排序器关键字
可用的关键字有:
readme:README.md或readme.md在前order: 正序在前并按其值升序排列,负序在后并按其值降序排列date: 按日期升序排序date-desc: 按日期降序排序title: 按标题字母顺序排序filename: 按文件名字母顺序排序
其类型为:
import type {
ThemeNormalPageFrontmatter,
ThemePageData,
} from "vuepress-theme-hope";
interface SidebarFileInfo {
type: "file";
filename: string;
title: string;
order: number | null;
path?: string | null;
frontmatter: ThemeNormalPageFrontmatter;
pageData: ThemePageData;
}
interface SidebarDirInfo {
type: "dir";
dirname: string;
children: SidebarInfo[];
title: string;
order: number | null;
groupInfo: {
icon?: string;
collapsible?: boolean;
link?: string;
};
frontmatter: ThemeNormalPageFrontmatter | null;
pageData: ThemePageData | null;
}
type SidebarInfo = SidebarFileInfo | SidebarDirInfo;
type SidebarSorterKeyword =
"readme" | "order" | "date" | "date-desc" | "filename" | "title";
type SidebarSorterFunction = (infoA: SidebarInfo, infoB: SidebarInfo) => number;
type SidebarSorter =
| SidebarSorterFunction
| SidebarSorterKeyword
| (SidebarSorterKeyword | SidebarSorterFunction)[];导航相关
breadcrumb
boolean默认值
true是否全局启用路径导航。
breadcrumbIcon
boolean默认值
true是否在路径导航显示图标。
prevLink
boolean默认值
true是否在页面底部显示上一篇链接。
nextLink
boolean默认值
true是否在页面底部显示下一篇链接。
页面元数据
titleIcon
boolean默认值
true是否在页面标题旁显示图标。
pageInfo
ArticleInfo[] | false默认值
["Author", "Original", "Date", "Category", "Tag", "ReadingTime"]文章信息,可以填入数组,数组的顺序是各条目显示的顺序。填入 false 使其被禁用。
可以填入的条目如下:
'Author': 作者'Date': 写作日期'Original': 是否原创'Category': 分类'Tag': 标签'ReadingTime': 预计阅读时间'Word': 字数'PageView': 页面浏览量
lastUpdated
boolean默认值
true是否显示页面最后更新时间。
contributors
'content' | 'meta' | boolean默认值
'meta'是否显示页面贡献者。
'content': 显示在页面内容中'meta': 显示在页面底部的元信息中true: 和'meta'相同false: 不显示
changelog
boolean是否显示变更日志。
editLink
boolean默认值
true是否展示编辑此页链接。
editLinkPattern
string编辑链接的匹配。其中 :repo :branch :path 会被自动替换为 docsRepo docsBranch 和 docsDir + filePath。
注
主题已经为 GitHub、Gitlab、Gitee 和 Bitbucket 提供了内置支持。
docsRepo
string默认值
repo文档仓库。
docsBranch
string默认值
'main'文档所在分支。
docsDir
string文档在仓库中的目录。
页脚
string页脚的默认内容,可输入 HTMLString。
copyright
string | false默认值
'Copyright © <作者>'默认的版权信息,设置为 false 来默认禁用它。
boolean是否默认显示页脚。
杂项
home
string默认值 当前 locale 的键名
当前语言的主页路径,用于导航栏图标和返回主页按钮的链接。
rtl
boolean是否使用 RTL 布局。
toc
GetHeadersOptions | boolean默认值
true是否显示标题列表。
false: 不显示标题列表number: 仅显示该级别的标题[number, number]: 标题级别元组,第一个数字应小于第二个数字,例如[2, 4],表示显示所有<h2>到<h4>的标题。'deep': 和[2, 6]相同,表示显示所有<h2>到<h6>的标题。
toc.selector
string默认值
'#markdown-content > h1, #markdown-content > h2, #markdown-content > h3, #markdown-content > h4, #markdown-content > h5, #markdown-content > h6, [vp-content] > h2'标题的选择器。
toc.ignore
string[]默认值
[".vp-badge", ".vp-icon"]忽略标题中的特定元素,应是一个 CSS 选择器数组。
toc.levels
HeaderLevels默认值
'deep'标题的级别。
1 到 6 对应 <h1> 到 <h6>
更新日志
2026/9/28 12:45
查看所有更新日志
0c1aa-于dd81e-于9a4c3-于9a31c-于e12a3-于9a004-于12a7b-于9f5ef-于1e314-于76d91-于4a9b3-于f91f0-于b1230-于d58b6-于73f6e-于41639-于a8a07-于794f9-于dc56d-于c2ba2-于04f3a-于e9f26-于13ace-于78b3c-于11463-于edf2d-于8174c-于aafa6-于6f20f-于5a6f8-于b81ad-于9df60-于5f9be-于7d314-于3e996-于3d007-于636cc-于9856d-于db823-于aae8c-于35972-于fd395-于1eb77-于bcf02-于de367-于e2478-于babc9-于0c093-于f6ff0-于6c43f-于892cc-于3c199-于