Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 多余的Jekly面包屑导航问题_Html_Jekyll_Breadcrumbs_Static Site - Fatal编程技术网

Html 多余的Jekly面包屑导航问题

Html 多余的Jekly面包屑导航问题,html,jekyll,breadcrumbs,static-site,Html,Jekyll,Breadcrumbs,Static Site,我有这个杰基尔代码,但它并不理想。目前,如果你访问一个结构为example.com/careers/job postings/的页面,它会显示为Home/careers/job postings。但如果你回到职业,那就是家/职业/职业。每一个都将最后一个子项作为非链接。 我怎样才能消除冗余或总体上改进这种逻辑?(我从其他地方获取了大部分代码。) {%capture url_parts%}{{page.url |删除:“/index.html”|替换:“/”,“}}{%endcapture%}

我有这个杰基尔代码,但它并不理想。目前,如果你访问一个结构为
example.com/careers/job postings/
的页面,它会显示为Home/careers/job postings。但如果你回到职业,那就是家/职业/职业。每一个都将最后一个子项作为非链接。 我怎样才能消除冗余或总体上改进这种逻辑?(我从其他地方获取了大部分代码。)


{%capture url_parts%}{{page.url |删除:“/index.html”|替换:“/”,“}}{%endcapture%}
{%capture num_parts%}{{url_parts}单词数|减:0}{%endcapture%}
{%assign previous=”“%}
{%如果num_parts==“0”或num_parts==“-1”%}
  • {%else%}
  • {%页中未使用。内容限制:num_parts%} {%capture first_word%}{{url_parts | truncatewords:1 |删除:“…”}{%endcapture%} {%capture-previous%}{{previous}}/{{first_-word}{%endcapture%}
  • {%capture url_parts%}{{url_parts |删除_first:first_word}{%endcapture%} {%endfor%} {%endif%} {%除非page.title==第一个单词%}
  • {{page.title}}
  • {%end除非%}

    离题;试试CodeReview.StackOverflow吧。如果你想改进你的代码,你真的应该按照TylerH的建议去问。
    <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> &nbsp; </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>