使用hexo创建blog

安装hexo

主要采用hexo工具本地生成技术知识库预览,hexo使用说明;
安装hexo必须先安装nodejs、npm

1
npm install hexo -g

创建blog

创建一个blog目录,进入其中执行:

1
2
3
4
5
6
7
8
9
10
11
hexo init
npm install --save hexo-filter-sequence
npm install --save hexo-filter-flowchart
npm install hexo-renderer-mathjax --save
npm install --save hexo-generator-feed
npm install hexo-filter-mermaid-diagrams --save
npm install hexo-generator-search --save
   # 解决TOC出现undefine问题
npm install markdown-it-named-headings --save
hexo clean
hexo g

编辑_config.yml添加以下内容:

1
2
3
4
5
6
7
8
9
10
11
12
flowchart:
  options: # options used for `drawSVG`

sequence:
  options: 
  theme: 
  css_class: 

mathjax:
  enable: true
#修改主题
theme: next

使用next主题,下载主题到themes中:

1
git clone https://github.com/iissnan/hexo-theme-next themes/next

next支持mermaid,在themes/next/layout/_partials/head/custom-head.swig中添加:

1
2
<script src="{{ url_for('https://unpkg.com/mermaid@'+theme.mermaid.version + '/dist/mermaid.min.js') }}"></script>
<script type="text/javascript">mermaid.initialize({startOnLoad:true,flowchart:{useMaxWidth:false, htmlLabels:true}});</script>

支持本地搜索,编辑thmem

1
2
local_search:
	enable: true #默认为false

创建tagscategories

1
2
hexo new page tags
hexo new page categories

编辑source/tags/index.md,改为:

1
2
3
4
title: 标签
date: 日期
type: "tags"
comments: false

编辑source/categories/index.md,改为:

1
2
3
4
title: 分类
date: 日期
type: "categories"
comments: false

将技术知识库仓库checkout

1
svn co http://192.168.7.3/svn/drops

复制drops下的文件内容到 blog/source/_posts/目录下;

1
cp -rf drops /blog/source/_posts/

执行hexo s启动本地服务,通过该方式进行预览。
使用hexo生成md文件:

1
hexo new "文章标题"

该动作会直接执行文件创建,会在source/_post/下生成一个”文章标题.md”的文件。

猜你喜欢

转载自blog.csdn.net/u012206617/article/details/84561469
今日推荐