You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Quarto网站中隐藏右侧边栏的「On this page」栏?

如何隐藏Quarto页面右侧的「On this page」栏

Quarto官方文档未明确提及该操作,但右侧的「On this page」属于页面的侧边目录(TOC)模块,以下两种方法可实现隐藏:

方法1:直接禁用目录(全局/单页)

如果不需要任何目录相关功能,直接关闭TOC即可让右侧「On this page」消失。

  • 单页文档配置:在文档开头的YAML块中添加:
---
title: "你的文档标题"
format:
  html:
    toc: false
---
  • 全局配置(所有页面生效):在项目根目录的_quarto.yml中设置:
format:
  html:
    toc: false

方法2:仅隐藏右侧侧边栏(保留锚点导航)

如果只想隐藏右侧的「On this page」栏,但保留页面标题的锚点跳转功能,可通过自定义CSS实现:

方式A:外部CSS文件

  1. 在项目中创建custom.css文件,添加以下样式:
/* 隐藏右侧On this page侧边栏 */
.toc-sidebar {
  display: none !important;
}
/* 调整主内容区域宽度,避免侧边栏消失后留白 */
.main-content {
  max-width: 100% !important;
  margin: 0 auto;
}
  1. 在文档YAML中引入该CSS:
---
title: "你的文档标题"
format:
  html:
    css: custom.css
---

方式B:内联样式块

直接在文档中添加CSS代码块(无需额外文件):

.toc-sidebar {
  display: none !important;
}
.main-content {
  max-width: 100% !important;
  margin: 0 auto;
}

内容的提问来源于stack exchange,提问作者its.me.adam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 22:09:58