Please add option to disable auto TOC in the wiki. #9513

Open
opened 2025-11-02 08:41:22 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @13BTurbo on GitHub (Sep 4, 2022).

Feature Description

The new auto generated Wiki TOC is making some wiki content, particularly tables or graphics, too narrow.
Please add an option to disable the auto generated TOC.

I have tried adding the below, but that does not disable the auto generated TOC from rendering.

gitea: none
include_toc: false

Screenshots

No response

Originally created by @13BTurbo on GitHub (Sep 4, 2022). ### Feature Description The new auto generated Wiki TOC is making some wiki content, particularly tables or graphics, too narrow. Please add an option to disable the auto generated TOC. I have tried adding the below, but that does not disable the auto generated TOC from rendering. gitea: none include_toc: false ### Screenshots _No response_
GiteaMirror added the type/proposaltype/feature labels 2025-11-02 08:41:22 -06:00
Author
Owner

@GlitterHorn commented on GitHub (Nov 23, 2022):

It would be helpful if the main content wrapped around the TOC, too. This issue has some screenshots.

@GlitterHorn commented on GitHub (Nov 23, 2022): It would be helpful if the main content wrapped around the TOC, too. [This issue](https://github.com/go-gitea/gitea/issues/822) has some screenshots.
Author
Owner

@GlitterHorn commented on GitHub (Nov 24, 2022):

You can use a custom template file to change or hide the auto TOC.

The file is custom/templates/repo/wiki/view.tmpl - make sure you grab the right version for your server; this tripped me up.

The TOC is rendered on lines 73-91. To hide the TOC, remove this section. If you move the section to the first child of the main content div and add some inline CSS, you can make the TOC wrap like this:

<div class="ui {{if or .sidebarPresent .toc}}eleven wide column{{end}} segment markup wiki-content-main" style="width:100% !important;">
	{{if or .sidebarPresent .toc}}
	<div id="wraptoc" class="column" style="width:33%;float:right;background-color:var(--color-box-body);padding-top: 0;">
		{{if .toc}}
			<div class="ui segment wiki-content-toc" style="margin: 10px 0 0 10px;">
				<details open>
					<summary>
						<div class="ui header">{{.i18n.Tr "toc"}}</div>
					</summary>
					{{$level := 0}}
					{{range .toc}}
						{{if lt $level .Level}}{{range Iterate (Subtract .Level $level)}}<ul>{{end}}{{end}}
						{{if gt $level .Level}}{{range Iterate (Subtract $level .Level)}}</ul>{{end}}{{end}}
						{{$level = .Level}}
						<li><a href="#{{.ID}}">{{.Text}}</a></li>
					{{end}}
					{{range Iterate $level}}</ul>{{end}}
				</details>
			</div>
		{{end}}
		{{if .sidebarPresent}}
			<div class="ui segment wiki-content-sidebar">
				{{if and .CanWriteWiki (not .Repository.IsMirror)}}
					<a class="ui right floated muted" href="{{.RepoLink}}/wiki/_Sidebar?action=_edit" aria-label="{{.i18n.Tr "repo.wiki.edit_page_button"}}">{{svg "octicon-pencil"}}</a>
				{{end}}
				{{template "repo/unicode_escape_prompt" dict "EscapeStatus" .sidebarEscapeStatus "root" $}}
				{{.sidebarContent | Safe}}
			</div>
		{{end}}
	</div>
	{{end}}
	{{template "repo/unicode_escape_prompt" dict "EscapeStatus" .EscapeStatus "root" $}}
	{{.content | Safe}}
</div>

This produces the following:

image

@GlitterHorn commented on GitHub (Nov 24, 2022): You can use a custom template file to change or hide the auto TOC. The file is [`custom/templates/repo/wiki/view.tmpl`](https://github.com/go-gitea/gitea/blob/main/templates/repo/wiki/view.tmpl) - make sure you grab the right version for your server; this tripped me up. The TOC is rendered on lines 73-91. To hide the TOC, remove this section. If you move the section to the first child of the main content div and add some inline CSS, you can make the TOC wrap like this: ```go <div class="ui {{if or .sidebarPresent .toc}}eleven wide column{{end}} segment markup wiki-content-main" style="width:100% !important;"> {{if or .sidebarPresent .toc}} <div id="wraptoc" class="column" style="width:33%;float:right;background-color:var(--color-box-body);padding-top: 0;"> {{if .toc}} <div class="ui segment wiki-content-toc" style="margin: 10px 0 0 10px;"> <details open> <summary> <div class="ui header">{{.i18n.Tr "toc"}}</div> </summary> {{$level := 0}} {{range .toc}} {{if lt $level .Level}}{{range Iterate (Subtract .Level $level)}}<ul>{{end}}{{end}} {{if gt $level .Level}}{{range Iterate (Subtract $level .Level)}}</ul>{{end}}{{end}} {{$level = .Level}} <li><a href="#{{.ID}}">{{.Text}}</a></li> {{end}} {{range Iterate $level}}</ul>{{end}} </details> </div> {{end}} {{if .sidebarPresent}} <div class="ui segment wiki-content-sidebar"> {{if and .CanWriteWiki (not .Repository.IsMirror)}} <a class="ui right floated muted" href="{{.RepoLink}}/wiki/_Sidebar?action=_edit" aria-label="{{.i18n.Tr "repo.wiki.edit_page_button"}}">{{svg "octicon-pencil"}}</a> {{end}} {{template "repo/unicode_escape_prompt" dict "EscapeStatus" .sidebarEscapeStatus "root" $}} {{.sidebarContent | Safe}} </div> {{end}} </div> {{end}} {{template "repo/unicode_escape_prompt" dict "EscapeStatus" .EscapeStatus "root" $}} {{.content | Safe}} </div> ``` This produces the following: ![image](https://user-images.githubusercontent.com/3516276/203679783-660c15ae-be97-4cca-a69c-62f1c5cebf74.png)
Author
Owner

@13BTurbo commented on GitHub (Nov 27, 2022):

Sure, that works fine for the entire site. But it would be more useful if it were possible on a per repository basis.

@13BTurbo commented on GitHub (Nov 27, 2022): Sure, that works fine for the entire site. But it would be more useful if it were possible on a per repository basis.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#9513