-
Notifications
You must be signed in to change notification settings - Fork 25.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Breadcrumbs has a wrong url at lastest position. #3097
Comments
Could consider it a bug. The breadcrumb was not carefully designed to handle multiple levels of hierarchy. It could only do one level (Home → Level 1 Hierarchy → Article). |
My content has many nested directories. I am also new to liquid, but managed to get this going for me. This would be a breaking change on people's format so I'm not sure how to best implement it. And given my experience here there may be a more elegant way to code this. But you (or a maintainer) are welcome to have at it. I rewrote that part of breadcrumbs.html page to use a different url rendering loop based on this example on stackoverflow by (@jhvanderschee) I also set this up to always render the root breadcrumb even on the root directory / homepage. By changing minimal-mistakes/_layouts/single.html Line 11 in 2632ff6
to I figure that you can always disable the breadcrumb on the root by setting the A friend suggested I could use {% capture %} to clean this up, but I'm not sure how. This is what I changed it to to get the correct urls. {% comment %} thanks to https://stackoverflow.com/a/32004173/42082 for how to fix urls {% endcomment %}
{% assign crumbs = (page.url | remove:'/index.html' | split: '/') %}
{% assign i = 1 %}
<li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
<a href="{{ '/' | relative_url }}" itemprop="item"><span itemprop="name">{{
site.data.ui-text[site.locale].breadcrumb_home_label | default: "Home" }}</span></a>
<meta itemprop="position" content="1" />
</li>
{% for crumb in crumbs offset: 1 %}
{% assign i = i | plus: 1 %}
<span class="sep">{{ site.data.ui-text[site.locale].breadcrumb_separator | default: "/" }}</span>
<li {% if forloop.last %}class="current"{% endif %} itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
<a href="{{ '' | relative_url }}{% assign crumb_limit = forloop.index | plus: 1 %}{% for crumb in crumbs limit: crumb_limit %}{% if forloop.last %}{{ crumb }}{% else %}{{ crumb | append: '/' }}{% endif %}{% endfor %}"
itemprop="item"><span itemprop="name">{{ crumb | replace: '-', ' ' | replace: '%20', ' ' | remove:'.html' }}</span></a>
<meta itemprop="position" content="{{ i }}" />
</li>
{% endfor %} Hope this helps! |
I noticed There is a PR in the pipeline that would make my aforementioned changes of disabling breadcrumbs on the '/' directory a reality. #3096 |
Environment
Expected behavior
Steps to reproduce the behavior
href
should be/dates/2021
Other
I have read the code below.
minimal-mistakes/_includes/breadcrumbs.html
Lines 17 to 38 in 0491cd3
I'm new on
liquid
, and have not totally understand what it is doing.But it looks like split current page url with
/
When
i = 2
, it will generate<a>
tag withhref
.But I don't see where the href handler is.
The text was updated successfully, but these errors were encountered: