Skip to content

current_page.ancestors only contains direct ancestor and not the full path of the page #693

@rickpeters

Description

@rickpeters

I'm using the mkdocs theme and tried to enhance it with a breadcrumb trail. The page navigation is created automatically by mkdocs (I don't use the pages confguration since I have almost 300 pages).
I copied and adapted the breadcrumbs.html file from the readthedocs theme and integrated it in content.html:

<ol class="breadcrumb">
<li><a href="{{ homepage_url }}">Docs</a></li>
{% if current_page %}
  {% for doc in current_page.ancestors %}
    {% if doc.link %}
      <li><a href="{{ doc.link|e }}">{{ doc.title }}</a></li>
    {% else %}
      <li>{{ doc.title }}</li>
    {% endif %}
  {% endfor %}
{% endif %}
{% if current_page %}<li>{{ current_page.title }}</li>{% endif %}
</ol>

My file path (starting from the docs_dir) is:
beheerteam/diensten/algemeen/ActiveDirectory.md
The generated breadcrumb trail is:
Docs/algemeen/ActiveDirectory

algemeen is the only part that originates from the loop for doc in current_page.ancestors.

Maybe this is a stupid question or it is just not possible, but I couldn't find i in the documentation and I'm just starting with mkdocs and couldn't understand the source on how this works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions