Table of Contents is quite tricky on multi devices.
To use toc add in the frontmatter
toc: true
The default layout contains a custom body
tag:
{% if page.toc %}
<body data-spy="scroll" data-target="#toc">
{% else %}
<body>
{% endif %}
Use for fixed navigation the affix
attribute. TOC can happen in page and post layouts.
<div class="container">
{% if page.toc == true %}
<div class="col-md-3"><nav id="toc" data-spy="affix" data-toggle="toc"></nav></div>
<div class="col-md-9">{{ content }}</div>
{% else %}
<div class="col-md-12">{{ content }}</div>
{% endif %}
</div>
Maybe the best solution?