Skip to content

Commit f0af407

Browse files
committed
Document content page TOC controls
1 parent 8a5391f commit f0af407

3 files changed

Lines changed: 90 additions & 1 deletion

File tree

pages/user-guide/extensions/02-markdown.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,41 @@ frontmatter:
7474
- `nav`: override or disable the inherited navigation.
7575
- `footer`: override or disable the inherited footer.
7676
- `comments`: page-level comments configuration when `webifier.comments` is enabled.
77+
- `toc`: enable or disable the generated table of contents for this page.
78+
- `content_pages`: page-level content-page controls such as `toc` and `cleanup`.
79+
80+
toc_controls:
81+
label: Table of Contents
82+
content: |
83+
Markdown content pages get a generated collapsible table of contents by
84+
default when they have enough headings. The TOC is built from `h1` through
85+
`h4` headings after Markdown is rendered.
86+
87+
Disable it for one Markdown page:
88+
89+
```text
90+
---
91+
title: Short Note
92+
toc: false
93+
---
94+
95+
# Short Note
96+
```
97+
98+
Or use the more explicit content-page block when you want to group related
99+
controls:
100+
101+
```text
102+
---
103+
title: Course Notes
104+
content_pages:
105+
toc: true
106+
cleanup: true
107+
---
108+
```
109+
110+
Site-wide defaults live under `content_pages` in the normal Webifier config.
111+
Page front matter wins over the site default.
77112
78113
linking:
79114
label: Typed Links

pages/user-guide/extensions/03-notebook.yml

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ yaml_preface:
7070
- `nav`: override or disable inherited navigation.
7171
- `footer`: override or disable inherited footer.
7272
- `comments`: page-level comments settings when comments are enabled.
73+
- `toc`: enable or disable the generated table of contents for this notebook page.
74+
- `colab`: enable or disable the Colab badge for this notebook page.
7375
7476
linking:
7577
label: Link a Notebook
@@ -96,11 +98,29 @@ colab:
9698
If Webifier is run with a repository name, notebook pages can include a
9799
Google Colab URL pointing to the source notebook in the repository. The
98100
standard bundled assets include a small Colab badge image for this workflow.
101+
Colab links are enabled by default for notebooks when `--repo-full-name` is
102+
available.
99103
100104
```bash
101105
webify --repo-full-name owner/repo --baseurl /repo
102106
```
103107
108+
Disable the badge for one notebook in the first Markdown cell:
109+
110+
```markdown
111+
---
112+
title: Local-only Notebook
113+
colab: false
114+
---
115+
```
116+
117+
Or set the site-wide notebook default:
118+
119+
```yaml
120+
notebook:
121+
colab: false
122+
```
123+
104124
assets_and_outputs:
105125
label: Assets and Outputs
106126
content: |
@@ -119,10 +139,31 @@ toc_and_polish:
119139
label: Table of Contents and Page Polish
120140
content: |
121141
The standard content page can build a collapsible table of contents from
122-
headings in notebook Markdown cells. That works best when notebooks use
142+
headings in notebook Markdown cells. Notebook content pages get this TOC by
143+
default when they have enough headings. That works best when notebooks use
123144
normal heading levels and do not also contain a hand-written table of
124145
contents cell.
125146
147+
Disable it for one notebook in the first Markdown cell:
148+
149+
```markdown
150+
---
151+
title: Tiny Notebook
152+
toc: false
153+
---
154+
```
155+
156+
Or use explicit content-page controls:
157+
158+
```markdown
159+
---
160+
title: Tiny Notebook
161+
content_pages:
162+
toc: true
163+
cleanup: true
164+
---
165+
```
166+
126167
Recommended notebook cleanup before publishing:
127168
128169
- Put metadata in the first Markdown cell as YAML front matter.

pages/user-guide/extensions/examples/tiny-markdown.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: Tiny Markdown Example
3+
toc: true
34
---
45

56
# Tiny Markdown Example
@@ -9,6 +10,18 @@ This file is rendered by linking to it with `md=...`.
910
Markdown files can carry YAML front matter for page-level metadata, then normal
1011
Markdown content below it.
1112

13+
## Discovery
14+
1215
- Webifier discovers the link.
1316
- Webifier creates a sibling HTML page.
1417
- The generated page shares the site shell, theme, navigation, and footer.
18+
19+
## Page Controls
20+
21+
The front matter at the top of this file sets `toc: true`, so the generated
22+
page gets a collapsible table of contents when enough headings are present.
23+
24+
## Content
25+
26+
The rest of the file is normal Markdown. You can use headings, lists, links,
27+
tables, math, code blocks, and inline HTML when you need it.

0 commit comments

Comments
 (0)