Hexo使用小结
一、安装
$ npm install -g hexo-cli
二、建站
$ hexo init <folder>
$ cd <folder>
$ npm install
修改hexo
站根目录下的_config.yml
文件:
# 设置站点属性
title: 大师之路
subtitle: ''
description: ''
keywords:
author: 老树
language: zh-CN
timezone: ''
# URL
url: https://yao_yu.gitee.io
root: /
三、使用NexT主题
下载主题
$ cd hexo
$ git clone https://github.com/theme-next/hexo-theme-next themes/hexo-theme-next
启用主题
修改hexo
站根目录下的_config.yml
文件:
theme: hexo-theme-next
四、启用Katex
1. 卸载默认渲染引擎
npm uninstall hexo-renderer-marked –save
2. 安装新渲染引擎和katex引擎
npm install hexo-renderer-markdown-it --save
npm install markdown-it-katex --save
3. 引擎设置
修改hexo
站根目录下的_config.yml
文件:
# Markdown-it config
## Docs: https://github.com/celsomiranda/hexo-renderer-markdown-it/wiki/
markdown:
render:
html: true
xhtmlOut: false
breaks: true
linkify: true
typographer: true
quotes: '“”‘’'
plugins:
anchors:
level: 2
collisionSuffix: ''
math:
engine: 'katex'
katex:
css: https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.11.1/katex.min.css
js: https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.11.1/katex.min.js
config:
# KaTeX config
throwOnError: false
errorColor: "#cc0000"
4. 开启NexT主题math支持
修改NexT主题
配置_config.yml
文件:
# Math Formulas Render Support
math:
# Default (true) will load mathjax / katex script on demand.
# That is it only render those page which has `mathjax: true` in Front-matter.
# If you set it to false, it will load mathjax / katex srcipt EVERY PAGE.
per_page: true
# hexo-renderer-pandoc (or hexo-renderer-kramed) required for full MathJax support.
mathjax:
enable: false
# See: https://mhchem.github.io/MathJax-mhchem/
mhchem: false
# hexo-renderer-markdown-it-plus (or hexo-renderer-markdown-it with markdown-it-katex plugin) required for full Katex support.
katex:
enable: true
# See: https://github.com/KaTeX/KaTeX/tree/master/contrib/copy-tex
copy_tex: false
五、调试
1. 生成静态文件
$ hexo generate
或
$ hexo g
2. 本地运行
$ hexo server
或
$ hexo s
3. 手动发布
将hexo\public
目录下的文件手动拷贝到发布git仓库,这样不会删除仓库里的内容