简体   繁体   中英

How to list all post categories in Jekyll?

I was thinking of using the following code snippet but it does not return anything...

{% for category in site.categories %}
        <li><a href="{{ category.url }}"><strong>{{ category.title }}</strong></a></li>
{% endfor %}

I'm also using Jekyll's original category page generator plugin , but I cannot figure out how to list all the post categories (for a blog page sidebar) that are being used?

Try this:

{% for category in site.categories %}
    <li><a href="{{category.url}}"><strong>{{category|first}}</strong></a></li>
{% endfor %}

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