Toc in posts not generating

I set toc: true in _config.yml, and I have also try to set it directly in my posts - but the table of contents just wont appear. Which is confusing, because it does work for my pages, but both are using the same layout (single).

I have been searching for quite a while now but I can’t seem to be finding the mistake - can someone help me please?

Table of contents isn’t supported on all layouts. If you’re using layout: single then toc: true should work.

But if you’re trying to enable on archive pages that list posts, that’s not going to work.

2 Likes

For example this post you have the TOC enabled correctly in front matter, but the layout should be single instead of posts

setting it to single did the trick - thanks. slightly counterintuitive though that posts doesn’t support toc, no?

EDIT: I think I finally understand - posts is for the posts archive / overview page - right?

That’s correct. Which is why the TOC isn’t part of that layout, typically you have multiple posts with excerpts on these pages and it wouldn’t make much sense to have table of contents for each.

1 Like