mluerig
November 15, 2021, 9:20pm
1
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
---
title: Hosting static websites with github pages and jekyll
layout: posts
date: 2021-11-15
tag-name: tech tutorials
description: How to host and easily maintain personal or lab-websites using github pages and jekyll.
og_image: /assets/images/posts/demo-hp-2.png
toc: true
toc_sticky: true
---
*This is a series of posts where I document some of the techy things I do for my work as a scientist. My motivation for these posts is to both document the procedures for myself and help share them among the science community. My goal is to focus on writing more posts rather than making each post all-encompassing, but if I am missing relevant information please do let me know and I will add it.*
I like the concept of a personal website to feature scientific interests, resources, or other relevant information related to working as a scientist. What I don't like is spending a lot of time manging content or dealing with bloated and unflexible website management systems, like wordpress.
With [github-pages](https://pages.github.com/){:target="_blank"}, a website and its content can be easily hosted and managed through a regular github repository - just like the one you are looking at right now. Together with [jekyll](https://jekyllrb.com/){:target="_blank"}, a generator for static websites that uses [markdown](https://www.markdownguide.org/getting-started/){:target="_blank"}, content management becomes incredibly simple. Here is a short introduction to get a website up and running in a few minutes.
For all the presented methods you will need a github account.
For additional guides (e.g. how to connect this do your own custom domain) and for links to free themes, see the end of this post.
This file has been truncated. show original
mluerig
November 16, 2021, 8:59am
4
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