hugo-theme-mini icon indicating copy to clipboard operation
hugo-theme-mini copied to clipboard

Setting up Table of Content for posts

Open b1azk0 opened this issue 7 years ago • 5 comments

Could you please tell me how can I set a TOC for posts? I write my stuff in RMarkdown (Rstudio) and push pandoc compiled htmls to github so that netlify can take care of the rest.

Is the TOC something I should set up in config.toml? I can't figure out how to make it work properly.

b1azk0 avatar Jan 04 '18 16:01 b1azk0

Generally only need to set enableToc = true in config.toml. And I use your config.toml to generate my .md files in exampleSite, it works fine. Could you upload to github or mail to me ([email protected]) all your Rstudio project files ? Let me have a look.

nodejh avatar Jan 05 '18 12:01 nodejh

Hmm... I guess this has to do with me working with .Rmd files for my posts (and not .md).

enableToc = true in config.toml was set fromday 1 and it never worked

Ive uploaded all the source files

b1azk0 avatar Jan 05 '18 12:01 b1azk0

Aha, I found your .Rmd files in your https://github.com/b1azk0/blog. I'll take a look now.

nodejh avatar Jan 05 '18 12:01 nodejh

One way of going around this issue, is by adding:

output:
  blogdown::html_page:
    toc: true
    toc_depth: 2

to a each post's yaml header.

It's not a solution as the TOC is ugly, but it's there (I updated my posts if you want to have a look)

Still the one that you have in your posts is much nicer

b1azk0 avatar Jan 05 '18 16:01 b1azk0

@b1azk0 , if you're using blogdown, or RStudio in general, use the .Rmarkdown file extension for your posts (not .Rmd) and it should inherit the css for the normal .md toc

ghost avatar Oct 29 '18 13:10 ghost