Closed hermanp closed 4 years ago
Need to adjust the settings startLevel
and endLevel
for goldmark renderer in config.toml:
If single.html
is modified as below (as Table of contents - Hugo docs suggests):
{{- define "main" -}}
<article class="article">
{{ partial "page_header" . }}
<div class="article-container">
<div class="article-style">
{{ .Content }}
</div>
{{ partial "page_footer" . }}
</div>
</article>
<!--- Below is added --->
<aside>
{{ .TableOfContents }}
</aside>
<!--- Above is added --->
{{- end -}}
Then the result is a TOC on the left side, as this picture shows:
After searched in Google for hugo "table of contents" OR toc aside
, found goHugo Table of Contents
Modified single.html
as:
{{- define "main" -}}
<article class="article">
{{ partial "page_header" . }}
<div class="article-container">
<div class="article-style">
{{ .Content }}
</div>
{{ partial "page_footer" . }}
</div>
</article>
<aside style="float: right;">
{{ .TableOfContents }}
</aside>
{{- end -}}
This happened:
In the end TOC for blog posts #1520 was modified at the if condition, according to Adding a useful Table of Contents to Hugo sites.
Get a table of contents (TOC, ToC) for a post page. Google search:
hugo "table of contents" OR toc
,hugo "table of contents" OR toc aside
andhugo "table of contents" OR toc float* OR aside