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

如何配置Quarto网站使首页仅显示侧边导航栏

如何让Quarto首页仅显示侧边导航栏

有几种可靠的方法可以实现这个需求,下面是具体步骤:

方法1:用CSS隐藏主体内容区域

  1. 在项目根目录新建styles.css文件,添加以下样式:
/* 隐藏首页的主体内容 */
body.quarto-home main.content {
    display: none;
}

/* 可选:让侧边栏铺满整个页面宽度 */
body.quarto-home div.quarto-sidebar {
    width: 100%;
    max-width: 100%;
}
  1. 在项目的_quarto.yml中引入这个CSS文件,确保侧边栏已启用:
project:
  type: website

format:
  html:
    css: styles.css
    sidebar: true

方法2:自定义页面类+空内容页

如果需要更精准地控制,可给首页单独设置自定义类:

  1. 编辑index.qmd,清空内容并添加YAML配置:
---
title: ""
format:
  html:
    class: "no-main-content"
---
  1. 在styles.css中添加针对这个类的样式:
body.no-main-content main.content {
    display: none;
}

body.no-main-content div.quarto-sidebar {
    width: 100%;
}

方法3:尝试Quarto内置布局参数(部分版本支持)

部分Quarto版本支持在页面YAML中直接关闭主体区域,可尝试在index.qmd中设置:

---
title: ""
format:
  html:
    page-layout: sidebar
    main: false
---

如果这个参数不生效,优先使用前面的CSS方法,兼容性更好。

内容的提问来源于stack exchange,提问作者ttalVlatt

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.20 04:45:55