Absolute Zola beginner here.
In version 0.5 I used the following loop to generate a full TOC for the entire section on every page:
{% set section = get_section(path="docs/_index.md") %}
{% for p in section.pages %}
<div class="bd-toc-item">
<a class="bd-toc-link" href="{{ p.permalink }}">{{ p.title }}</a>
<ul>
{% for s in p.toc %}
<li class="bd-sidenav">
<a href="{{ s.permalink }}">{{ s.title }}</a>
</li>
{% endfor %}
</ul>
</div>
{% endfor %}
But in 0.6+ only the toc for the current page is available as a global variable. Is there a way to generate the full table of contents in a page?
Is there a way to generate the full table of contents in a page?
No. I didn't think anyone would use the toc like that - I looked at quite a few sites/templates from various SSG before making the change but never saw a ToC outside of the page itself.
Ok no problem, I'm just starting anyway. I only have a few pages with a few items each so in my case it fit nicely. I'll rethink the design.
Thanks for the quick reply.
Hmm I just realised when trying to update one of my site from Gutenberg to Zola that I was using almost exactly the sample you have in the issue 馃う鈥嶁檪 : the side bar of https://tera.netlify.com/docs/installation/ is made like that. I should have checked my own sites 馃う鈥嶁檪
That's a totally valid usecase, I assume yours is similar - I'll think about it.
I'm looking for this as well. In my case I get to page variables from a global context via get_taxonomy. I'd like to be able to present the subheadings at this level. Something like get_toc(page) would do the trick for me, but I don't know much about the constraints on the API design here.
(I'm attempting to rewrite https://magnushoff.com/articles/asmtut/ with Zola, dynamically populating the list from posts tagged #asmtut rather than manually updating the overview page)
FYI this is done and will be in 0.10
Most helpful comment
FYI this is done and will be in 0.10