Skip to content

per page toc start level #767

@inphobia

Description

@inphobia

#765 & #766 were things i ran into trying to figure out the subject of this ticket.

is there any way to set a toc start level on a per page (or directory) basis? i have a few pages where i'd like a startlevel of 1, but only a few. for the rest i prefer startlevel 2.

it seems that the only place where markup's depth is accepted is in the main hugo.toml/yaml

[markup]
  [markup.goldmark.renderer]
    unsafe = true
  [markup.tableofcontents]
    startlevel = 1
    endlevel = 4

i tried every variation of frontmatter i could think of in both toml & yaml syntax but only the startlevel in hugo.toml has effect. (booktoc true/false does work per page)

i know that i have a lot of double parameters, this is just to show what/where i tried in frontmatter:

---
date: '2025-09-04T16:54:32+02:00'
title: 'first steps in the sas world'
description: 'first steps in the sas world'
weight: 20
BookToc: true
markup:
  tableOfContents:
    startLevel: 3
params:
  eid: here
  BookToc: true
  markup:
    tableOfContents:
      startLevel: 3
---

none of it had any effect. if it's indeed defined only in the main hugo file then feel free to close this issue.

thx in advance

(eid param is for https://github.com/boevski/hugo elink shortcode for linking by unique id)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions