Code blocks receive compact headers automatically in Toha—showing the language or custom filename alongside a complete-source Copy button and optional folding controls configured globally in hugo.yaml or overridden per fence.
Auto-folded long configuration (previewLines: 8)
Because params.features.codeBlock.folding.enable is true with previewLines: 8, long blocks show an approachable preview while keeping the full text available to Copy even before expanding:
module:
imports:
- path: github.com/hugo-toha/toha/v4
params:
home:
layout: portfolio
features:
componentsDesign:
enable: true
portfolio:
enable: true
modern:
enable: true
navigation: bar
hero:
style: photo
search:
enable: true
codeBlock:
copyButton:
enable: true
folding:
enable: true
previewLines: 8
Initially expanded with line numbers & custom limit
Use fence attributes like title="...", data-expand=true, data-max-lines=5, and linenos=inline to customize presentation on specific examples:
1package backup
2
3import (
4 "context"
5 "fmt"
6 "time"
7)
8
9func RunSnapshot(ctx context.Context, volumeID string) error {
10 deadline, cancel := context.WithTimeout(ctx, 30*time.Second)
11 defer cancel()
12
13 select {
14 case <-deadline.Done():
15 return fmt.Errorf("snapshot %s timed out: %w", volumeID, deadline.Err())
16 default:
17 return nil
18 }
19}
Compact output logs & plain text
Fences without an explicit language get a generic label and can still specify title and data-max-lines:
[1/4] Generating build statistics (hugo_stats.json)
[2/4] Compiling semantic Tailwind CSS tokens
[3/4] Bundling modern portfolio and blog scripts
[4/4] Built 93 pages cleanly in 1.2s
Short commands stay open
Short snippets under the preview threshold display inline with zero collapse noise:
mise run portfolio