Jekyll 回路液体在现场工作,但不在现场工作

Jekyll 回路液体在现场工作,但不在现场工作,jekyll,liquid,osx-elcapitan,Jekyll,Liquid,Osx Elcapitan,我刚开始开发新的OSX 10.11.2。我顺利安装了Jekyll和所有依赖项,然后在本地克隆了此repo: 当我从repository()查看实时站点时,默认布局中的Liquid循环成功地在侧栏中生成了一个页面树。但当我在本地提供站点时,侧栏是空的。我不明白为什么会这样。有什么想法吗 以下是循环: {% for item in site.collections %} {% assign collection = item[1] %} {% if section %}

我刚开始开发新的OSX 10.11.2。我顺利安装了Jekyll和所有依赖项,然后在本地克隆了此repo:

当我从repository()查看实时站点时,默认布局中的Liquid循环成功地在侧栏中生成了一个页面树。但当我在本地提供站点时,侧栏是空的。我不明白为什么会这样。有什么想法吗

以下是循环:

{% for item in site.collections %}
    {% assign collection = item[1] %}
    {% if section %}
        {% if collection.output %}
            {% assign next = collection %}
            {% break %}
        {% endif %}
    {% elsif url contains collection.active_prefix %}
        {% assign section = collection.title %}
        {% assign items = collection.docs | sort: 'order' %}
    {% elsif collection.output %}
        {% assign previous = collection %}
    {% endif %}
{% endfor %}

谢谢

Github页面使用的是Jekyll2.4,而您在本地使用的是Jekyll3.x

不同之处在于Jekyll集合迭代器在2和3中的行为不同

jekyll2返回:
Array[String,Hash]
jekyll3返回:
Hash

因此,您的
{%assign collection=item[1]]}
在使用Jekyll 3时失败

Jekyll 2/3兼容代码可以是:

{% for item in site.collections %}
    {% assign itemLength = item | size %}
    {% comment %}Jekyll 2 returns an array with length = 2{% endcomment %}
    {% if itemLength == 2 %}
        {% assign collection = item[1] %}
    {% else %}{% comment %}Jekyll 3 returns a hash with length > 2{% endcomment %}
        {% assign collection = item %}
    {% endif %}
    {% if collection.output %}
        {% assign parts = url | split: "/" %}
        <li class="nav-item top-level {% if parts[1] == collection.active_prefix %}current{% endif %}">
            {% assign items = collection.docs | sort: 'order' %}
            <a href="{{ items.first.url }}">{{ collection.title }}</a>
            {% include secondary-nav-items.html items=items %}
        </li>
    {% endif %}
{% endfor %}
{%用于site.collections%}
{%assign itemLength=项目|大小%}
{%comment%}Jekyll 2返回一个长度为2的数组{%endcomment%}
{%if itemLength==2%}
{%assign集合=项[1]}
{%else%}{%comment%}Jekyll 3返回长度大于2的哈希值{%endcomment%}
{%assign collection=item%}
{%endif%}
{%if collection.output%}
{%assign parts=url |拆分:“/”%}
  • {%assign items=collection.docs | sort:'订单'%} {%include secondary-nav-items.html items=items%}
  • {%endif%} {%endfor%}

    为了与Github页面设置同步,您可以使用bundler和Gemfile

    Github页面使用的是Jekyll2.4,而您在本地使用的是Jekyll3.x

    不同之处在于Jekyll集合迭代器在2和3中的行为不同

    jekyll2返回:
    Array[String,Hash]
    jekyll3返回:
    Hash

    因此,您的
    {%assign collection=item[1]]}
    在使用Jekyll 3时失败

    Jekyll 2/3兼容代码可以是:

    {% for item in site.collections %}
        {% assign itemLength = item | size %}
        {% comment %}Jekyll 2 returns an array with length = 2{% endcomment %}
        {% if itemLength == 2 %}
            {% assign collection = item[1] %}
        {% else %}{% comment %}Jekyll 3 returns a hash with length > 2{% endcomment %}
            {% assign collection = item %}
        {% endif %}
        {% if collection.output %}
            {% assign parts = url | split: "/" %}
            <li class="nav-item top-level {% if parts[1] == collection.active_prefix %}current{% endif %}">
                {% assign items = collection.docs | sort: 'order' %}
                <a href="{{ items.first.url }}">{{ collection.title }}</a>
                {% include secondary-nav-items.html items=items %}
            </li>
        {% endif %}
    {% endfor %}
    
    {%用于site.collections%}
    {%assign itemLength=项目|大小%}
    {%comment%}Jekyll 2返回一个长度为2的数组{%endcomment%}
    {%if itemLength==2%}
    {%assign集合=项[1]}
    {%else%}{%comment%}Jekyll 3返回长度大于2的哈希值{%endcomment%}
    {%assign collection=item%}
    {%endif%}
    {%if collection.output%}
    {%assign parts=url |拆分:“/”%}
    
  • {%assign items=collection.docs | sort:'订单'%} {%include secondary-nav-items.html items=items%}
  • {%endif%} {%endfor%}

    为了与Github页面设置同步,您可以使用bundler和Gemfile

    想知道这个问题是否与Jekyll3是本地安装的,而github页面仍然在Jekyll2.4上这一事实有关,根据这个页面:您的存储库url是什么?很抱歉。这里是:想知道这个问题是否与Jekyll3是本地安装的,而github页面仍然在Jekyll2.4上这一事实有关,根据这个页面:你的存储库url是什么?很抱歉。这是: