前言

Pacman 是一款为 Hexo 打造的一款扁平化,有着响应式设计的主题。 由于 Pacman 已经暂停更新,加上 Hexo 已经升级为 3.0,很多主题需要重新适配,而 Jacman 是基于 Pacman 修改而来,在前端设计样式和功能上做了很多合理的修改和完善,相信你也一定可以很快上手。

Jacman 是一款基于 Pacman 修改并坚持更新的 Hexo 主题


更新历史

2019 年 11 月 24 日

阅读原文 - https://liaojiaxin158.github.io/post/hexo-jacman/

扩展阅读


主题安装

设置很简单,请参考原文中文说明

Jacman

http://wuchong.me/blog/2014/11/20/how-to-use-jacman/


配置 yml

这是我自己的真实配置文件,请参考原文注释做修改

全局 yml

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site
title: HelloDog
subtitle: Keep Calm and Carry On
description: HelloDog 是一个基于 Github 和 Hexo 的静态 Blog,希望用简单而清晰的写作方式 Markdown 分享自己的心得体会。
author: liaojiaxin
language: zh-CN
timezone:

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: https://liaojiaxin158.github.io # with the https protocol
enforce_ssl: liaojiaxin158.github.io # without any protocol
root: /
permalink: post/:title/
permalink_defaults:

# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:

# Writing
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link: true # Open external links in new tab
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight:
enable: true
line_number: true
tab_replace:

# Category & Tag
default_category: uncategorized
category_map:
tag_map:

# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss

# Pagination
## Set per_page to 0 to disable pagination
per_page: 10
pagination_dir: page

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: jacman

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type:

# Others
index_generator:
per_page: 5 ## 首页默认 10 篇文章标题 如果值为 0 不分页

archive_generator:
per_page: 0 ## 归档页面默认 10 篇文章标题
yearly: true ## 生成年视图
monthly: true ## 生成月视图

tag_generator:
per_page: 0 ## 标签分类页面默认 10 篇文章

category_generator:
per_page: 0 ### 分类页面默认 10 篇文章

feed:
type: atom ##feed 类型 atom 或者 rss2
path: atom.xml ##feed 路径
limit: 20 ##feed 文章最小数量

主题 yml

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
##### Menu
menu:
主页 | Home: /
索引 | Index: /index/
归档 | Archives: /archives/
简介 | About: /about/
## you can create `tags` and `categories` folders in `../source`.
## And create a `index.md` file in each of them.
## set `front-matter`as
## layout: tags (or categories)
## title: tags (or categories)
## ---

#### Widgets
widgets:
- github-card
- category
- links
- rss
## provide eight widgets:github-card,category,tag,rss,archive,tagcloud,links,weibo

#### RSS
rss: /atom.xml ## RSS address.

#### Image
imglogo:
enable: true ## display image logo true/false.
src: img/logo.png ## `.svg` and `.png` are recommended,please put image into the theme folder `/jacman/source/img`.
favicon: img/favicon.ico ## size:32px*32px,`.ico` is recommended,please put image into the theme folder `/jacman/source/img`.
apple_icon: img/jacman.jpg ## size:114px*114px,please put image into the theme folder `/jacman/source/img`.
author_img: img/author.jpg ## size:220px*220px.display author avatar picture.if don't want to display,please don't set this.
banner_img: #img/banner.jpg ## size:1920px*200px+. Banner Picture
### Theme Color
theme_color:
theme: '#ea6753' ##the defaut theme color is blue

# 代码高亮主题
# available: default | night
highlight_theme: night

#### index post is expanding or not
index:
expand: false ## default is unexpanding,so you can only see the short description of each post.
excerpt_link: Read More

close_aside: true #close sidebar in post page if true
mathjax: false #enable mathjax if true

### Creative Commons License Support, see http://creativecommons.org/
### you can choose: by , by-nc , by-nc-nd , by-nc-sa , by-nd , by-sa , zero
creative_commons: none

#### Author information
author:
intro_line1: "Hello, I'm OX. This is my blog on GitHub." ## your introduction on the bottom of the page
intro_line2: "Keep Calm and Carry On." ## the 2nd line
weibo: ## e.g. wuchong1014 or 2176287895 for http://weibo.com/2176287895
weibo_verifier: ## e.g. b3593ceb Your weibo-show widget verifier ,if you use weibo-show it is needed.
tsina: ## e.g. 2176287895 Your weibo ID,It will be used in share button.
douban: ## e.g. wuchong1014 or your id for https://www.douban.com/people/wuchong1014
zhihu: ## e.g. jark for http://www.zhihu.com/people/jark
email: ## e.g. imjark@gmail.com
twitter: ## e.g. jarkwu for https://twitter.com/jarkwu
github: liaojiaxin ## e.g. wuchong for https://github.com/wuchong
facebook: ## e.g. imjark for https://facebook.com/imjark
linkedin: aowang ## e.g. wuchong1014 for https://www.linkedin.com/in/wuchong1014
google_plus: ## e.g."111190881341800841449"for https://plus.google.com/u/0/111190881341800841449, the"" is needed!
stackoverflow: ## e.g. 3222790 for http://stackoverflow.com/users/3222790/jark
## if you set them, the corresponding share button will show on the footer

#### Toc
toc:
article: true ## show contents in article.
aside: true ## show contents in aside.
## you can set both of the value to true of neither of them.
## if you don't want display contents in a specified post,you can modify `front-matter` and add `toc: false`.

#### Links
links:
Jark's Blog: http://wuchong.me
LinkedIn: https://www.linkedin.com/in/jiaxinliao

#### Comment
duoshuo_shortname: ## e.g. wuchong your duoshuo short name.
disqus_shortname: liaojiaxin ## e.g. wuchong your disqus short name.
gentie_key: ## your 163 gentie key, see https://gentie.163.com/
changyan_appid: ## changyan app id, see http://changyan.kuaizhan.com/
changyan_appkey: ## changyan app key, see http://changyan.kuaizhan.com/

#### Share button
jiathis:
enable: false ## if you use jiathis as your share tool,the built-in share tool won't be display.
id: 1503875 ## e.g. 1889330 your jiathis ID.
tsina: 1913082125 ## e.g. 2176287895 Your weibo id,It will be used in share button.

#### Analytics
google_analytics:
enable: true
id: UA-77732745-1 ## e.g. UA-46321946-2 your google analytics ID.
site: liaojiaxin158.github.io ## e.g. wuchong.me your google analytics site or set the value as auto.
## You MUST upgrade to Universal Analytics first!
## https://developers.google.com/analytics/devguides/collection/upgrade/?hl=zh_CN
baidu_tongji:
enable: true
sitecode: c2c5fc7d844d0973d9f77abd87f49c3c ## e.g. e6d1f421bbc9962127a50488f9ed37d1 your baidu tongji site code
cnzz_tongji:
enable: false
siteid: ## e.g. 1253575964 your cnzz tongji site id

#### Miscellaneous
ShowCustomFont: true ## you can change custom font in `variable.styl` and `font.styl` which in the theme folder `/jacman/source/css`.
fancybox: true ## if you use gallery post or want use fancybox please set the value to true.
totop: true ## if you want to scroll to top in every post set the value to true

#### Custom Search
google_cse:
enable: false
cx: ## e.g. 018294693190868310296:abnhpuysycw your Custom Search ID.
## https://www.google.com/cse/
## To enable the custom search You must create a"search"folder in'/source'and a"index.md"file
## set the'front-matter'as
## layout: search
## title: search
## ---
baidu_search: ## http://zn.baidu.com/
enable: false
id: "3783770861532079376" ## e.g."783281470518440642"for your baidu search id
site: http://zhannei.baidu.com/cse/search ## your can change to your site instead of the default site

swiftype: ## https://swiftype.com/
enable: true

内容发布

修改 post 预设格式

建议按照个人习惯修改 hexo\scaffolds 中的 post.md

1
2
3
4
title: {{ title }}
date: {{ date }}
categories:
description:

生成文章

文章如含有有中文请修改编码为 UTF-8 避免乱码

  1. 命令生成初始文章,文件名空格会自动加 -hyphen 中横线
1
hexo n "hexo post"
  1. hexo\source\_posts 中编辑生成出来的 hexo-post 文件
1
2
3
4
5
6
title: hexo post #可以改成中文的,如 “新文章”
date: 2015-01-14 21:31:42 #发表日期,可自定义修改排序
categories: blog #文章文类
tags: [博客, 文章] #文章标签,可以加入多标签
---
# 这里是正文,用 Markdown 书写
  1. 本地预览文章内容,登录 localhost:4000 查看效果

    1
    hexo s
  2. 发布内容到 public 文件夹,然后我选择手动复制同步到 GitHub

    1
    2
    hexo clean
    hexo g

导航栏添加自定义页面

  1. 命令手动生成自定义页面

    1
    hexo n page "about"
  2. 编辑 hexo/source/about/index.md 内容

  3. 修改 themes/jacman/_config.yml 文件
    1
    2
    menu:
    关于: /about

其它修改

RSS 和 sitemap

  1. 安装 RSS 和 sitemap 插件

    1
    2
    npm install hexo-generator-feed@1 --save
    npm install hexo-generator-sitemap@1 --save
  2. 开启 RSS 和 sitemap 功能,编辑 hexo/_config.yml

    1
    2
    3
    4
    feed:
    type: atom #feed 类型 (atom/rss2)
    path: atom.xml #rss 路径
    limit: 20 #在 rss 中最多生成的文章数 (0 显示所有)
  3. 修改 thems/jacman/_config.yml,编辑 Widgets 和 rss

    1
    2
    3
    4
    5
    #### Widgets
    widgets:
    - rss

    rss: /atom.xml
  4. 手动提交生成出来的 atom.xml 文件给搜索引擎

添加 404 页面

在 GitHub 根目录下如 liaojiaxin158.github.io 设置 404.html 即可,建议使用 腾讯公益 404

1
2
3
4
5
6
7
8
9
<html>
<head>
<meta charset="UTF-8" />
<title>404 | HelloDog</title>
</head>
<body>
<script type="text/javascript" src="http://www.qq.com/404/search_children.js" charset="utf-8"></script>
</body>
</html>

网站统计

Jacman 自带的选择足够了

站内搜索

swiftype - https://swiftype.com/

利用 swiftype 为 hexo 添加站内搜索 v2.0
http://www.jerryfu.net/post/search-engine-for-hexo-with-swiftype-v2.html

常见错误

  1. 修改配置文件时注意 YAML 语法,参数 冒号: 后一定要留 空格
  2. 中文乱码请修改文件编码格式为 UTF-8
  3. GitHub 同步慢或者失败请使用代理加速

Hexo 自动部署至 GitLab

网上很多已经有很多方法了,常见的可能有 2 种思路,当然也有人选择容器或者 Bitcron

  1. 基于 hexo deploy 一键部署
  2. 基于 Travis CI 自动部署 Hexo 到 GitHub

我想满足的需求和大家一样越简单越好,只是我更多时候在本地编辑通过 Evernote 和 Dropbox 同步数据,发送至 liaojiaxin158.github.io 的 GitHub Page 中,其实仔细思考一下用最纯粹的命令不就好了。

以 Windows 10 环境 PowerShell 为例,在 Git Shell 家目录创建 deploy_hexo.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# hexo g
cd .\hexo
hexo clean
hexo g

# del old files
cd ..\liaojiaxin158.github.io
Remove-Item about,archives,categories,css,fancybox,font,img,index,js,page,post -recurse -force

# deploy github
Copy-Item ..\hexo\public\* .\ -recurse -force
git add *
git commit -m "mod"
git push
文章目录
  1. 1. 前言
  2. 2. 更新历史
  3. 3. 主题安装
    1. 3.1. Jacman
  4. 4. 配置 yml
    1. 4.1. 全局 yml
    2. 4.2. 主题 yml
  5. 5. 内容发布
    1. 5.1. 修改 post 预设格式
    2. 5.2. 生成文章
    3. 5.3. 导航栏添加自定义页面
  6. 6. 其它修改
    1. 6.1. RSS 和 sitemap
    2. 6.2. 添加 404 页面
    3. 6.3. 网站统计
    4. 6.4. 站内搜索
  7. 7. 常见错误
  8. 8. Hexo 自动部署至 GitLab