私はこの jekyll コードを持っていますが、理想的ではありません。example.com/careers/job-postings/
現在、 Home / Careers / Job Postings のような構造のページにアクセスすると問題なく表示されます。しかし、キャリアに戻ると、それは Home / Careers / Careers です。それぞれに、リンクされていない最後の子があります。冗長性を取り除くか、このロジックを一般的に改善するにはどうすればよいですか? (このコードのほとんどは他の場所から取得しました。)
<div class="breadcrumbs">
<div class="wrap">
{% capture url_parts %} {{ page.url | remove: "/index.html" | replace:'/'," " }}{% endcapture %}
{% capture num_parts %}{{ url_parts | number_of_words | minus: 0 }}{% endcapture %}
{% assign previous="" %}
<ol>
{% if num_parts == "0" or num_parts == "-1" %}
<li><a href="/">home</a> </li>
{% else %}
<li><a href="/">home</a></li>
{% for unused in page.content limit:num_parts %}
{% capture first_word %}{{ url_parts | truncatewords:1 | remove:"..."}}{% endcapture %}
{% capture previous %}{{ previous }}/{{ first_word }}{% endcapture %}
<li><a href="{{previous}}">{{ first_word }}</a></li>
{% capture url_parts %}{{ url_parts | remove_first:first_word }}{% endcapture %}
{% endfor %}
{% endif %}
{% unless page.title == first_word %}
<li>{{ page.title }}</li>
{% endunless %}
</ol>
</div>