简体   繁体   中英

Sorting posts by category using Jekyll works locally but not on Github pages?

I have posts in Jekyll sorted by categories that wont display on github pages. The yaml font matter in the post has the categories set to CSS and design but don't display on the category page with the code below:

{% for post in site.categories.CSS %}
    {% if post.url %}
       <a id="h1a" href="{{ post.url }}">{{ post.title }}</a>
        <p id="date">{{ post.author }} • {{ post.date | date: "%b %-d, %Y" }}</p>
        <div id="excerpt">{{ post.excerpt }}  </div>
        <div id="readmore"><a href="{{ post.url | prepend: site.baseurl }}">Read More</a></div>
     {% endif %}
{% endfor %}

It works locally, and the URL path (/css/design/2016/01/10/responsive-web-design-css-viewport.html) shows that the categories are there, but does not display in the link above. Here is my repository , the code above can be found in the css folder of the root directory.

Jekyll 3.x uses categories "as is" : CSS stays CSS .

Jekyll 2.x is down-casing categories : CSS becomes css .

So, on Github pages site.categories.CSS == nil

In order to work locally in Github pages configuration, you can follow install instructions here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM