Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Quick Start

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

1
$ hexo server

More info: Server

Generate static files

1
$ hexo generate

More info: Generating

Deploy to remote sites

1
$ hexo deploy

More info: Deployment

公式配置教程

1.首先卸载hexo-math和hexo-renderer-marked。然而hexo应该是没有自带hexo-math的,所以只需要卸载第二个就行。以防万一还是可以直接执行:

1
2
npm un hexo-math
npm un hexo-renderer-marked
  1. 安装hexo-renderer-pandoc渲染器
1
npm i hexo-renderer-pandoc
  1. 然后是配置主题配置下的mathjax设置。我用的是butterfly,那么对应路径是: _config.yml
1
2
3
4
# MathJax
mathjax:
enable: true
per_page: true

注意这步是要在主题配置文件中进行配置!

  1. 最后去Pandoc官网下载最新版本pandoc安装即可使用了。

自动更新

通过MD5检测实现自动更新。

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
import os
import time
import hashlib


def getMd5(input_path):
with open(input_path, 'rb') as f:
md5 = hashlib.md5(f.read()).hexdigest()
return md5



md_path=r"D:\GithubBlog\blog\source\_posts"

md5_dict={}


def init():
for root, dirs, files in os.walk(md_path, topdown=False):
for name in files:
file_path=os.path.join(root, name)
if file_path.endswith(".md"):
md5_dict[file_path]=getMd5(file_path)
for name in dirs:
print(os.path.join(root, name))

init()

while True:

is_update=False
for root, dirs, files in os.walk(md_path, topdown=False):
for name in files:
file_path=os.path.join(root, name)
if file_path.endswith(".md"):
now_md5=getMd5(file_path)
if file_path not in md5_dict.keys():
is_update=True
md5_dict[file_path]=now_md5
else:
if md5_dict[file_path]!=now_md5:
md5_dict[file_path]=now_md5
is_update=True
if is_update:
os.system("hexo g")

time.sleep(20)