[TOC]
参考链接
hexo 安装
1 | npm install -g hexo-cli |
初始化 hexo
1 | hexo init |
启动本地服务器
1 | hexo s |
浏览器访问网址:
部署到远端 github
- 安装
hexo-deployer-git
插件
1 | npm install hexo-deployer-git --save |
- 需要设置文件:特别关键
- 修改
_config.yml
(在站点目录下)。文件末尾修改为
1 | # 部署到 github 远端 |
- 推送到GithubPages
1 | hexo g |
至此框架就搭好了
next
主题
主题下载
1 | git clone https://github.com/theme-next/hexo-theme-next themes/next |
更改站点配置文件_config.yml
的 theme
字段,为主题文件夹的名称:
1 | # Extensions |
更新到远端
1 | hexo clean & hexo g & hexo d |
设置 语言
- 编辑 站点配置文件, 将 language 设置成你所需要的语言。建议明确设置你所需要的语言,例如选用简体中文,配置如下:
1 | language: zh-Hans |
设置 菜单
- 编辑 主题配置文件,修改以下内容:
- 设定菜单内容,对应的字段是 menu。 菜单内容的设置格式是:
item name: link
。其中item name
是一个名称,这个名称并不直接显示在页面上,她将用于匹配图标以及翻译
- 设定菜单内容,对应的字段是 menu。 菜单内容的设置格式是:
下载
1 | hexo init |
设置 语言
更改站点配置文件
_config.yml
的theme
字段,为主题文件夹的名称:1
2
3
4Extensions
# Plugins: https://hexo.io/plugins/
# Themes: https://hexo.io/themes/
theme: next
设置名称 与语言
1 | Site |
设置 菜单
编辑 主题配置文件
设置菜单项的显示文本。在第一步中设置的菜单的名称并不直接用于界面上的展示。Hexo 在生成的时候将使用 这个名称查找对应的语言翻译,并提取显示文本。这些翻译文本放置在 NexT 主题目录下的
languages/{language}.yml
({language}
为你所使用的语言)。以简体中文为例,若你需要添加一个菜单项,比如
something
。那么就需要修改对应的翻译文件languages/zh-CN.yml
,在menu
字段下添加一项:
1 | menu: |
设置 头像
- 把图片放入
themes/next/source/images
下
打开themes/next/_config.yml
文件,搜索Sidebar Avatar
关键字
设置为url: /images/epigenetics.png
友情链接
- 打开
themes/next/_config.yml
文件,搜索关键字social
,然后添加社交站点名称与地址即可。
1 | social: |
友情链接图标
1 | # 打开主题配置文件themes/next/_config.yml,搜索social_icons:,在图标库找自己喜欢的小图标,并将名字复制在如下位置,保存即可 |
点击页面浮出文字
- ①、鼠标特效很简单,打开
\themes\next\layout\_layout.swig
文件,在末尾< /body>
前添加如下代码:
1 | <script type="text/javascript"> |
添加萌萌哒
1 | 安装插件 |
炫酷动态背景
- 参考链接:https://blog.csdn.net/sunshine940326/article/details/69933696
- 添加修改代码
next/layout/_layout.swig
在</body>
之前加上
1 | {% if theme.canvas_nest %} |
- 在菜单中添加链接。编辑
next\_config.yml
文件 - 主题配置文件中找到
canvas_nest
,设置成ture
1 | canvas_nest: ture |
在网站底部加上访问量
参考链接:https://chrischen0405.github.io/2018/09/11/post20180911/
打开
themes/next/layout/_partial/footer.swig
文件,在copyright
前加入以下代码:1
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
一般显示站点访问量在页脚,所以我们选择在
footer.swig
中添加标签,同时我们还可以通过修改主题配置来方便选择是否显示访问量,步骤如下:首先,我们在next主题下的_config.yml
中加入以下配置:1
2# visitors count
counter: true之后可以更改counter的值为false来隐藏页脚的访问量统计,然后,我们在
themes/next/layout/_partial/footer.swig
中添加以下代码:1
2
3
4
5
6{% if theme.footer.counter %}
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<span id="busuanzi_container_site_pv">本站总访问量<span id="busuanzi_value_site_pv"></span>次</span>
<span class="post-meta-divider">|</span>
<span id="busuanzi_container_site_uv">本站访客数<span id="busuanzi_value_site_uv"></span>人</span>
{% endif %}
统计功能
hexo 3.9以前报废
:新链接 https://github.com/theme-next/hexo-symbols-count-time3.9 版本
1 | npm install hexo-symbols-count-time --save |
站点下
_config.yml
添加- Activate this plugin in hexo’s _config.yml (which locates in the root dir of your blog) by enabled any option:
1
2
3
4
5
6symbols_count_time:
symbols: true
time: true
total_symbols: true
total_time: true
exclude_codeblock: falsenext 主题下
_config.yml
添加1
2
3
4
5
6
7symbols_count_time:
separated_meta: true
item_text_post: true
item_text_total: false
awl: 4
wpm: 275
suffix: mins.
RSS
参考链接:https://juejin.im/post/5c6d20b151882562934c9962#heading-42
在Hexo根目录,安装插件运行如下命令:
1 | npm install --save hexo-generator-feed |
在站点配置文件_config.yml中,添加如下内容:
1
2
3Extensions
# Plugins: https://hexo.io/plugins/
plugins: hexo-generate-feed然后再主题配置文件中配置
rss
1
rss: /atom.xml
添加评论模块
来必利 https://www.livere.com/my_Livere
参考链接:
- https://zhuanlan.zhihu.com/p/33617273
- https://www.tryagin.cn/HEXO%E5%8D%9A%E5%AE%A2%E5%8A%A0%E4%B8%8A%E6%9D%A5%E5%BF%85%E5%8A%9B%EF%BC%88livere%EF%BC%89%E8%AF%84%E8%AE%BA/#%E6%8E%A5%E5%85%A5%E5%90%88%E9%80%82%E7%9A%84%E8%AF%84%E8%AE%BA
- 顶级参考链接:https://juejin.im/post/5bebfe51e51d45332a456de0#heading-29
点击上方的安装,选择免费的city版本。
打开主题目录下的
/themes/next/_config.yml
配置文件,定位到livere_uid
字段,粘贴上刚刚复制的UID
打开 next 主题下
_config.yml
文件,定位到livere_uid
,添加下列信息MTAyMC80NTM4OS8yMTkwMQ 1
2
3
4
5
6
7
8
9
10
11
#### 显示当前浏览进度
- 修改`themes/*/_config.yml`,把 false 改为` true:`
```shell
# Back to top in sidebar
b2t: true
# Scroll percent label in b2t button
scrollpercent: true
添加网站底部跳动的心
1.在主题配置文件中(
themes/*/_config.yml
),更改footer
;1
垃圾功能毁我重来。
页脚统计信息
- NexT 6.x.x 直接添加了统计的信息,直接将next主题文件夹中的 _config.yml 中
busuanzi
统计打开 即可。
搜索功能
安装插件
hexo-generator-searchdb
,如下:1
npm install hexo-generator-searchdb --save
编辑
站点配置文件
,新增以下内容到任意位置,如下:
1 | search: path: search.xml field: post format: html limit: 10000 |
- 编辑
主题配置文件
,启用本地搜索功能,如下:
1 | # Local searchlocal_search: enable: true |
添加标签页面
- 新建页面
1 | hexo new page tags |
设置页面类型,编辑刚新建的页面,将页面的类型设置为 tags ,主题将自动为这个页面显示标签云
1
2
3
4title: 标签
date: 2019-07-18 20:46:32
type: "tags"
---如果有集成评论服务,页面也会带有评论。 若需要关闭的话,请添加字段 comments 并将值设置为 false,如:
1
2
3
4
5title: 标签
date: 2019-07-18 20:46:32
type: "tags
comments: false
---
添加分类
1 | hexo new page categories |
新建页面的模板
主目录的
scaffolds
目录下,是新建页面的模板,执行新建命令时,是根据这里的模板页来完成的,所以可以在这里根据你自己的需求添加一些默认值。所以我们可以打开
scaffolds/post.md
文件,在tages:上面加入categories:,保存后,之后执行hexo new 文章名
命令生成的文件,页面里就有categories:
项了
1 | --- |
翻页设置
共有两处,用于控制每一页显示多少篇博文
1
2
3
4
5
6
7
8
9
10
11
12
13# Home page setting
# path: Root path for your blogs index page. (default = '')
# per_page: Posts displayed per page. (0 = disable pagination)
# order_by: Posts order. (Order by date descending by default)
index_generator:
path: ''
per_page: 12
order_by: -date
# Pagination
## Set per_page to 0 to disable pagination
per_page: 12
pagination_dir: pageper_page:
后设置博文数量,0代表不翻页全部平铺显示
代码块高亮主题
- Next主题内置了tomorrow代码高亮主题,一共有五个,可以去Tomorrow查看预览效果,在下面的
highlight_theme:
中改成自己想要的即可
1 | # Code Highlight theme |
博文压缩
打开
themes/next/_config.yml
文件, 搜索auto_excerpt
, 将false
改为true
1
2
3
4
5Automatically Excerpt. Not recommand.
Please use <!-- more --> in the post to control excerpt accurately.
auto_excerpt:
enable: true
length: 150
修改文章底部的那个带 #
号的标签
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15编辑 themes/next/layout/_macro/post.swig,搜索rel="tag">#,将 # 换成<i class="fa fa-tag"></i>
修改下面为
<div class="post-tags">
{% for tag in post.tags %}
<a href="{{ url_for(tag.path) }}" rel="tag">{{ tag_indicate }} {{ tag.name }}</a>
{% endfor %}
</div>
a
<div class="post-tags">
{% for tag in post.tags %}
<a href="{{ url_for(tag.path) }}" rel="tag"><i class="fa fa-tag"></i> {{ tag.name }}</a>
{% endfor %}
</div>
分类页面添加年分类卡
- 找到 next 主题下的
\layout\category.swig
文件,查找for post in page.posts
可以看到如下代码:
1 | {% for post in page.posts %} |
选中这三行,修改为:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16{% for post in page.posts %}
{# Show year #}
{% set year %}
{% set post.year = date(post.date, 'YYYY') %}
{% if post.year !== year %}
{% set year = post.year %}
<div class="collection-title">
<h2 class="archive-year motion-element" id="archive-year-{{ year }}">{{ year }}</h2>
</div>
{% endif %}
{# endshow #}
{{ post_template.render(post) }}
{% endfor %}然后在文件末尾加上如下代码:
1
2
写文
1
hexo new post "my first post"
1 | --- |