Hexo相关命令

Hexo相关命令,以及我对Hexo和Next的修改日志

hexo的api

https://hexo.io/zh-cn/docs/writing.html

hexo的常用命令

1
2
3
4
5
6
7
8
hexo server -p 4001
hexo new [layout] <title>
hexo clean
hexo g
hexo d

hexo clean && hexo g && hexo d
hexo clean && hexo g && hexo server -p 4001

评论系统

https://ioliu.cn/2017/add-valine-comments-to-your-blog/

修改日志

特定段落缩进

1
2
3
4
5
6
7
8
9
10
11
12
// 特定段落(标志ooNoIndent00)缩进
// 是因为修改了~\blog\themes\next\source\js\src\bootstaps.js 文件
// 添加了下面一段话
// 特定段落(标志ooNoIndent00)缩进
$('p:contains("ooNoIndent00")').each(function() {
var str = $(this).text();
if (str.match("ooNoIndent00")) {
var text = $(this).html();
$(this).css('text-indent', '0em');
$(this).html(text.replace('ooNoIndent00', ''));
}
});

密码输入

1
2
3
4
5
6
7
8
9
10
11
12
13
// ~\blog\themes\next\layout\_partials\head.swig
<!-- #增加个输入密码的功能 # -->

<script>
(function(){
if('{{ page.password }}'){
if (prompt('请输入文章密码') !== '{{ page.password }}'){
alert('密码错误!');
location.href='/'
}
}
})();
</script>

首页隐藏

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// ~\blog\themes\next\layout\index.swig
<!-- #增加个首页隐藏的功能 # -->
{% block content %}

<section id="posts" class="posts-expand">
{% for post in page.posts %}
{% if post.visible !== 'hide' %}
{{ post_template.render(post, true) }}
{% endif %}
{% endfor %}
</section>

{% include '_partials/pagination.swig' %}
{% endblock %}

首行缩进

1
2
3
4
5
6
7
// ~\blog\themes\next\source\css_custom\custom.styl:
// Custom styles.
// 设置段落首行缩进(text-indent),调整段落下部间距
.post-body p {
text-indent: 0em;
margin-bottom: 0.8em;
}

增加站点搜索功能

搜索功能真心好用,当文章多起来的时候,标签提供的作用已经很少了,只能简单索引,搜索却能精确查找,这里我用的依旧是最简单的本地站内搜索。

安装插件

1
npm install hexo-generator-searchdb --save

修改站点配置文件

1
2
3
4
5
search:
path: search.xml
field: post
format: html
limit: 10000

修改主题配置文件

1
2
local_search:
enable: true

修改hexo文章链接

HEXO默认的文章链接形式为domain/year/month/day/postname,默认就是一个四级url,并且可能造成url过长,对搜索引擎是十分不友好的,我们可以改成 domain/postname 的形式。编辑站点_config.yml文件,修改其中的permalink字段改为permalink: :title.html即可。

站点地图

https://www.cnblogs.com/php-linux/p/8493181.html