如何在Jekyll中更改默认订单页面? [英] How to change the default order pages in Jekyll?

查看:71
本文介绍了如何在Jekyll中更改默认订单页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的博客是由Jekyll在Github上构建的.在导航栏中,默认顺序为页面",消息",关于",档案".我想将列表更改为页面",档案",关于",消息".我该怎么办?

My blog is built with Jekyll on Github. In the navigation bar, the default order is Pages, Messages, About, Archives. I want to change the list to Pages, Archives, About, Messages. What should I do?

我认为这与下面的代码有关

I think it is related to the code below

{% assign pages_list = site.pages %}

我认为site.pages是我应该更改的,但是我不知道如何.

I think site.pages is what I should change, but I don't know how.

推荐答案

导航栏菜单的顺序由_layout中的HTML模板(可能是从_includes中提取HTML片段)确定.

The order of your navbar menu is determined by the HTML template in _layout (which may be pulling in HTML fragments from _includes.

听起来您的导航栏是通过site.pages中使用液体代码的页面列表以编程方式生成的

It sounds like your navbar is being programatically generated from the list of pages provided in site.pages using the liquid code

{% assign pages_list = site.pages %}

如果页面数量很少,您可能希望手动将列表写出来. site.pages是Jekyll所有页面的字母列表.没有什么能阻止您对它进行硬编码了:

If you have only a small number of pages, you may prefer to just write the list out manually. site.pages is Jekyll's alphabetical list of all pages. Nothing stops you from just hardcoding this instead:

 <div class="navbar" id="page-top">
      <div class="navbar-inner">
        <div class="container">
          <a class="brand" href="/">EverCoding.net</a>
          <ul class="nav">
            <li><a href="/pages.html">Pages</a></li>        
        <li><a href="/archive.html">Archive</a></li>
        <li><a href="/about.html">About</a></li>
        <li><a href="/messages.html">Messages</a></li>

鉴于我目前正在以编程方式生成该列表,可能是通过遵循Jekyll-bootstrap的液体代码方式进行的:

Whereas I'm guessing at the moment you have that list generated programmatically, perhaps by following the way Jekyll-bootstrap does with liquid code:

<div class="navbar">
      <div class="navbar-inner">
        <div class="container">
          <a class="brand" href="{{ HOME_PATH }}">{{ site.title }}</a>
          <ul class="nav">
            {% assign pages_list = site.pages %}
            {% assign group = 'navigation' %}
            {% include JB/pages_list %}
          </ul>
        </div>
      </div>
    </div>

如果您真的想每次确定菜单,那么第二个示例中的简洁代码很方便,但是如果您有一个静态菜单的静态菜单,那么最好像我第一个示例中那样手动编写代码,而不是修改液体代码进行排序.

The liquid code in this second example is handy if you really want to determine the menu each time, but if you have a static menu in a static order you are probably best coding it by hand as in my first example, rather than modifying the liquid code to sort.

如果您可以链接到Jekyll来源,而不是已发布的博客,则我们可以更具体.

If you could link to the Jekyll source, rather than the published blog, we could be more specific.

这篇关于如何在Jekyll中更改默认订单页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆