Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content: Add option to display Table of Contents #258

Closed
palmierieugenio opened this issue Aug 30, 2017 · 4 comments
Closed

Content: Add option to display Table of Contents #258

palmierieugenio opened this issue Aug 30, 2017 · 4 comments

Comments

@palmierieugenio
Copy link

Is it possible to put a table of Contents with links inside a post? For long posts it can be useful.

I've tried with toc: true in the header of the file, but it just gives a "true" at the beginning of the post.

@gcushen gcushen changed the title Table of Contents TOC Content: Add option to display Table of Contents Sep 1, 2017
@gcushen
Copy link
Collaborator

gcushen commented Sep 3, 2017

Thanks for the feature request - the feature has just been added. Please update the theme and then use {{% toc %}} in your content where you wish to display the table of contents. If using non-English translation, you may also need to update your language file. Refer to the example in 06dc780 for more info.

Also note that there is currently a minor bug in Hugo concerning the nesting of the generated list - see gohugoio/hugo#1778 .

Let me know if you have any feedback. I'll re-open this if there are any issues.

@gcushen gcushen closed this as completed Sep 3, 2017
@palmierieugenio
Copy link
Author

palmierieugenio commented Sep 13, 2017

I've updated the en.yaml (since I'm using english) and I've created the toc.html file in the shortcodes folder, but I'm getting just the title "Table of Contents", without the actual list below.

I've seen the topic 1778, but I have little experience with css and html and I wasn't able to make it work. Maybe the problem is that I'm using Rmarkdown files instead of Markdown. I just get this as output, like a normal code chunk:

      {{ partial "banner" . }}
      {{ partial "table-of-contents" . }}
      <!-- supports emoji -->
      {{ .Content | emojify }}

@palmierieugenio
Copy link
Author

Yes: it works with Markdown files, but not with Rmarkdown files. :)

@pat-s
Copy link

pat-s commented Dec 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants