Skip to content

Instantly share code, notes, and snippets.

@VincentLoy
Last active June 19, 2024 16:52
Show Gist options
  • Save VincentLoy/e693aa1f149a59f465a5a71b6d937b9a to your computer and use it in GitHub Desktop.
Save VincentLoy/e693aa1f149a59f465a5a71b6d937b9a to your computer and use it in GitHub Desktop.
Easy snippet to get breadcrumb in a Wagtail page
<div class="breadcrumb-content">
{% if self.get_ancestors|length > 1 %}
<ul class="breadcrumb">
{% for p in self.get_ancestors %}
{% if p.is_root == False %}
<li><a href="{{ p.url }}">{{ p.title }}</a></li>
{% endif %}
{% endfor %}
<li class="active">{{ self.title }}</li>
</ul>
{% endif %}
</div>
@ismayil-ismayilov
Copy link

ismayil-ismayilov commented Jun 19, 2024

Unfortunately, I do not think that's a case for me. I strongly believe I caused a confusion since I may not have the same application method as you refer, sorry about it.

I used your Wagtail repo. It still hits DB.

This is my "simplified" Page class. I basically, applied your method to create a breadcrumb. Nothing more or less.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment