---
title: "布局"
description: "Nimbus 提供的页面外壳，以及如何按页面或全局关闭侧栏。"
---

> Documentation Index
> Fetch the complete documentation index at: https://nimbus-docs.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 布局

布局是用户拥有的 `.astro` 文件，位于 `src/layouts/`。脚手架工具会生成它们；你可以自由编辑。

<h2 id="the-shells">页面外壳</h2>

- **`BaseLayout`** — 最外层外壳：`<html>`、`<head>`、主题引导、字体预加载、元数据。所有内容都渲染在它内部。
- **`DocsLayout`** — 文档页面结构：侧边栏导航、内容栏、目录、面包屑导航、上一页/下一页。内容页面的默认布局。
- **`ShowcaseLayout`** — 组件展示结构，用于 `/components` 集合。

因为这些是你的文件，移除某个 UI 元素的方式就是直接从布局中删除它 — 从 `DocsLayout` 中去掉 `<Pagination />`，它就会在全站消失。

<h2 id="per-page-toggles">按页面切换</h2>

通过 frontmatter 可以关闭单个栏位，无需修改布局文件：

```yaml
---
title: 宽页面
sidebar: false           # 隐藏侧边栏导航
tableOfContents: false   # 隐藏目录栏
---
```

对于不需要任何文档 UI 元素的页面 — 如着陆页或营销页 — 使用 `mode: custom`：

```yaml
---
title: 欢迎
mode: custom
---
```

<h2 id="site-wide-toggles">全局切换</h2>

Nimbus 配置中的 `features` 块可以在全局范围内关闭某个栏位。合并逻辑是 AND — 只有当全局标志和按页面字段都同意时，该栏才会渲染：

```ts title="astro.config.ts"
nimbus({
  /* … */
  features: {
sidebar: true,
tableOfContents: false,   // 所有页面都不显示目录
  },
});
```

全局设为 `false` 后无法通过按页面选项覆盖：全局关闭的栏位会始终保持关闭。

Source: https://nimbus-docs.cn/styling/layouts/index.mdx
