<%# this page will judge whether current page is 'category.' url:'http://localhost:4000/category/' return false. url:'http://localhost:4000/categories/test/' return true. if you enter 'category' page by click link will show all categories. otherwise if you enter 'categories' by click post header link will show the single category of this post. how to add a category page: 1. hexo new page "category" 2. cd source/category/index.md 3. add layout pattern like this: --- title: '''category''' date: 2019-06-09 09:56:49 layout: category --- %> <% if(is_category()){ %> <%- partial('_page/category', {pagination: config.category, index: true}) %> <% }else{ %>

分类

<% site.categories.forEach(category_item=>{ %> <%# console.log("hehe") %>

<%- category_item.name %>

<% category_item.posts.forEach((post_item, index = 0)=>{ %> <%# console.log(index) %> <% if(++index <= 5){ %> <% } %> <% }) %> <% if(category_item.posts.length > 5){ %> More >> <% } %>
<% }) %>
<% } %>