最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

quarto - number-depth ignored in _quarto.yml - Stack Overflow

programmeradmin5浏览0评论

By some reason, the sidebar resulting from the following _quarto.yml file displays the main section only, the actual value in number-depth (eg, 3) seems ignored:

project:
  type: website

website:
  title: "Patatin Patatan"
  
  navbar:
    logo: "HSILab.png"
    left:
      - href: index.qmd
        text: Home
      - about.qmd
      - citation.qmd
  sidebar:
    logo: "HSILab.png"
    style: "docked"
    search: true
    number-sections: true
    number-depth: 3
    contents:
      - section: "Introduction"
        contents:
          - 00_Abstract.qmd
          - 01_Approach.qmd
      - section: "Methods"
        contents:
          - 02_Methods.qmd
      - section: "Results VISNIR"
        contents:
          - 03_Quality.qmd
          - 04_ImageSequences.qmd
          - 05_IQMosaics.qmd
          - _051_SimpleReferencing.qmd
          - _052_ImageStitching.qmd
      - section: "Results SWIR"
        contents:
          - 06_SWIR.qmd
      - section: "Conclusions"
        contents:
          - 07_Conclusions.qmd
format:
  html:
    theme: default
    css: styles.css
    toc: false
    toc-location: right
    code-fold: true
    code-summary: "code"
    page-layout: full
    smooth-scroll: true
    anchor-sections: true

editor: visual

Resulting sidebar:

By some reason, the sidebar resulting from the following _quarto.yml file displays the main section only, the actual value in number-depth (eg, 3) seems ignored:

project:
  type: website

website:
  title: "Patatin Patatan"
  
  navbar:
    logo: "HSILab.png"
    left:
      - href: index.qmd
        text: Home
      - about.qmd
      - citation.qmd
  sidebar:
    logo: "HSILab.png"
    style: "docked"
    search: true
    number-sections: true
    number-depth: 3
    contents:
      - section: "Introduction"
        contents:
          - 00_Abstract.qmd
          - 01_Approach.qmd
      - section: "Methods"
        contents:
          - 02_Methods.qmd
      - section: "Results VISNIR"
        contents:
          - 03_Quality.qmd
          - 04_ImageSequences.qmd
          - 05_IQMosaics.qmd
          - _051_SimpleReferencing.qmd
          - _052_ImageStitching.qmd
      - section: "Results SWIR"
        contents:
          - 06_SWIR.qmd
      - section: "Conclusions"
        contents:
          - 07_Conclusions.qmd
format:
  html:
    theme: default
    css: styles.css
    toc: false
    toc-location: right
    code-fold: true
    code-summary: "code"
    page-layout: full
    smooth-scroll: true
    anchor-sections: true

editor: visual

Resulting sidebar:

Share Improve this question asked 2 days ago user2955884user2955884 5623 silver badges14 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

number-depth should not have an effect here. In particular, the documentation on Side Navigation does not list it as an available option. You could instead use approaches as described below.

Auto Generation

The sidebar can be auto generated by using a suitable directory structure. For your example with the three levels you could use something like this:

Directory structure

.
├── _quarto.yml
├── index.qmd
└── 01_Section
    ├── index.qmd
    ├── 011_Subsection.qmd
    └── 012_Subsection
        ├── index.qmd
        ├── 0121_Subsubsection.qmd
        └── 0122_Subsubsection.qmd

As stated in the documentation:

Navigation item titles will be read from the title field of documents.

Hence you could use the following contents for obtaining the result shown at the end of the answer.

_quarto.yml

Use contents: auto:

...
sidebar:
  style: "docked"
  search: true
  contents: auto
...

01_Section/index.qmd

---
title: "Section 1"
---

01_Section/011_Subsection.qmd

---
title: "Subsection 1.1"
---

01_Section/012_Subsection/index.qmd

---
title: "Subsection 1.2"
---

01_Section/012_Subsection/0121_Subsubsection.qmd

---
title: "Subsubsection 1.2.1"
---

01_Section/012_Subsection/0122_Subsubsection.qmd

---
title: "Subsubsection 1.2.2"
---

Manual generation

You can define a third level section and contents, e.g. such that your _quarto.yml contains something like this:

sidebar:
  style: "docked"
  search: true
  contents:
    - section: "Section 1"
      contents:
        - 01_ImageSequences.qmd
        - section: "Subsection 1.2"
          contents: 
            - text: "Subsubsection 1.2.1"
              href: _011_SimpleReferencing.qmd
            - text: "Subsubsection 1.2.2"
              href: _012_ImageStitching.qmd

Result

发布评论

评论列表(0)

  1. 暂无评论