-
-
Save Phlow/a0e3fa686eb259fe7f76 to your computer and use it in GitHub Desktop.
<h2>Categories</h2> | |
<ul> | |
{% assign categories_list = site.categories %} | |
{% if categories_list.first[0] == null %} | |
{% for category in categories_list %} | |
<li><a href="#{{ category | downcase | downcase | url_escape | strip | replace: ' ', '-' }}">{{ category | camelcase }} ({{ site.tags[category].size }})</a></li> | |
{% endfor %} | |
{% else %} | |
{% for category in categories_list %} | |
<li><a href="#{{ category[0] | downcase | url_escape | strip | replace: ' ', '-' }}">{{ category[0] | camelcase }} ({{ category[1].size }})</a></li> | |
{% endfor %} | |
{% endif %} | |
{% assign categories_list = nil %} | |
</ul> | |
{% for category in site.categories %} | |
<h3 id="{{ category[0] | downcase | url_escape | strip | replace: ' ', '-' }}">{{ category[0] | camelcase }}</h3> | |
<ul> | |
{% assign pages_list = category[1] %} | |
{% for post in pages_list %} | |
{% if post.title != null %} | |
{% if group == null or group == post.group %} | |
<li><a href="{{ site.url }}{{ post.url }}">{{ post.title }} <time datetime="{{ post.date | date_to_xmlschema }}" itemprop="datePublished">{{ post.date | date: "%B %d, %Y" }}</time></a></li> | |
{% endif %} | |
{% endif %} | |
{% endfor %} | |
{% assign pages_list = nil %} | |
{% assign group = nil %} | |
</ul> | |
{% endfor %} |
Thanks , but I cant slide categorie posts when I click a categorie.
On line 10, should "#{{ tag[0] }}"
be #{{ category[0] }}
?
Anyway, I got the top snippet working for me that way. Thank you for this!
Hey @cayirburak, I just saw your comment and you're right. I deleted the <span>
Hey @bethanyvwatson – my code is confusing, but correct. The tag
is just a placeholder from the loop {% for tag in site.categories %}
– But I changed it to category
to get rid of the unnecessary confusing. Thankyou for pointing it out.
@cayirburak I corrected the code. Thankyou.
How can I create a page for each category automatically in Jekyll ?
example:
the url of the post : https://UsrNm.github.io/Category1/Category2/2018/02/16/Post1.html
I want when I go to link like: https://UsrNm.github.io/Category1/Category2/
Get All posts in category Category1
and Category2
or when I go to link like: https://UsrNm.github.io/Category2/
Get All posts in category Category2
only
when i click the category, my posts don't show up. do I have to set the permalink and create a page?
because now it just points to category/year/month/day/category
Let's say I don't use a default front-matter variable like tags
or categories
, but instead a non-default one like author
/ authors
in each post? I does work for categories, I have these too, but I want it for authors too.
If i replace site.categories
with site.authors
I get a Liquid Exception: 0 is not a symbol nor a string in xxx.html
You've forgot about closing
</span>
in line 23.</time></span></a>
Full version here https://gist.github.com/konstantin-morenko/1c301ad5a6cca6cded99e6726cf2f71a