whiteplain icon indicating copy to clipboard operation
whiteplain copied to clipboard

Can not show TOC by default

Open Honghe opened this issue 7 years ago • 2 comments

I can not see TOC by default. This is my page: http://localhost:1313/blog/posts/init/ Can you help to explain? Thanks!

image

Honghe avatar Mar 01 '18 14:03 Honghe

TOC will be automatically displayed in articles with more than 400 words. But, Hugo can not count word well in Chinese, Korean and Japanese.

If you add toc: true to Front matter of your articles, you can forcibly display TOC.

 ---
 title: "Title of Article"
 date: 2018-01-15T00:04:00+09:00
+toc: true
 ---

By copying themes/whiteplain/layout/partials/toc.html to layout/partcials/toc.html and deleting the if statements, you can display TOC in all articles regardless of the number of words.

-{{- if or .Params.toc (and (gt .WordCount 400 ) (ne .Params.toc "false")) }}
 <aside class="toc">
   {{ .TableOfContents }}
 </aside>
-{{- end }}

taikii avatar Mar 01 '18 22:03 taikii

Hi @taikii,

I'll use this relevant issue to ask a question: what is your policy on adding new variables in config.toml? Does one can add whatever option fits their need? For instance, for this issue, we could add an option minWordCountToShowToc. If set to 0, this would always show the toc. I have another idea that could use a new option as well: in the archive page, group the articles by years instead of months.

I can submit one PR for each if it's ok

As always, thank you for your work.

Nodraak avatar May 04 '19 11:05 Nodraak