1. _config.yml

    1
    2
    3
    4
    5
    6
    menu: 
    Home: /
    Archives: /archives
    Tags: /tags
    Categories: /categories
    About: /about
  2. categories tags

    1
    2
    $ hexo new page 'categories'
    $ hexo new page 'tags'

相应的index.md为:

1
2
3
4
5
6
---
title: 标签
date: 2019-05-23 23:37:02
type: "tags"
comments: false
---
1
2
3
4
5
6
---
title: 分类
date: 2019-05-23 23:37:13
type: "categories"
comments: false
---

主题nav.pug修改

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
.page-top.animated.fadeInDown
.nav
li
if is_home()
a.current(href="/")= __('首页')
else
a(href="/")= __('首页')
li
if is_archive()
a.current(href="/archives")= __('归档')
else
a(href="/archives")= __('归档')
li
if is_category()
a.current(href="/categories")= __('分类')
else
a(href="/categories")= __('分类')
li
if is_tag()
a.current(href="/tags")= __('标签')
else
a(href="/tags")= __('标签')
li
if is_current('about')
a.current(href="/about")= __('关于')
else
a(href="/about")= __('关于')

主题page.pug 修改

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
extends partial/layout

block site_title
!= page.title + " · " + config.title

block description

block content
if page.type === 'tags'
.autopagerize_page_element: .content
div.tag
.tag-cloud__title= page.title
span.tag-cloud__amount= site.tags.length
.tag-cloud-tags!= tagcloud({min_font: 12, max_font: 30, amount: 200, color: true, start_color: '#A4D8FA', end_color: '#0790E8'})
else if page.type === 'categories'
.autopagerize_page_element: .content
.cat
.category__title= page.title
span.category__amount= site.categories.length
div!= list_categories()
else
.autopagerize_page_element: .content: .post-page
include mixins
+make_post(page, true)
if page.comments
include partial/comments

对应样式添加

写了几个简单的样式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
.tag,.cat{
text-align: center;
margin-top: 20px;
}
.category__title,.tag-cloud__title{
display: inline-block;
}
.category-list{
text-align: center;
padding: 0;
}
.tag-cloud-tags a{
font-size: 16px !important;
color: #42b983 !important;
}
.tag-cloud-tags a:hover{
color: #a4d8fa !important;
}
.category-list-item{
list-style: none;
}

发布即可

1
2
3
$ hexo clean
$ hexo g
$ hexo d