{# "On this page" for the current document. MkDocs hands the heading tree to the theme as `page.toc` and nothing else surfaces it, so without this a long page offers no way to see its sections or jump between them. `theme.toc` says what the reader gets: auto the right rail where the window is wide enough for a third column, otherwise in the flow under the page title — expanded either way, which is how GitHub's own documentation reads expanded always in the flow, expanded; never takes the rail collapsed always in the flow, as a disclosure the reader opens hidden not rendered at all; `false` does the same An unrecognised value falls through to the `auto` behaviour, which is how the theme treats the rest of its options. Only `collapsed` is a
: the other shapes have nothing to click open, so giving them a disclosure would promise a control that does nothing useful. python-markdown nests the whole document under its single h1, which is already the page title on screen; descend past it when that is the shape, so the list starts at the h2 level. #} {%- set toc_mode = config.theme.toc %} {%- if toc_mode and toc_mode != 'hidden' and page and page.toc %} {%- set entries = page.toc | list %} {%- if entries | length == 1 and entries[0].children %} {%- set entries = entries[0].children | list %} {%- endif %} {# One entry is the page itself; there is nothing to navigate between. #} {%- if entries | length > 1 %} {%- set toc_label = gettext('On this page') %} {%- if toc_mode == 'collapsed' %}
{{ toc_label }}
{%- else %}
{{ toc_label }}
{%- endif %} {# In the rail the outline is already where it belongs. In the flow it reads as part of the page, so it belongs under the title — but the title comes from the Markdown, inside page.content, where a template cannot reach. Moving it is cosmetic: with no JavaScript it stays above the article and works exactly the same. #} {%- endif %} {%- endif %}