1.安装node.js
Hexo需用通过npm安装,而npm需要node,现在只要安装node 就自带 npm了
1 | 执行命令查看是否安装成功: |
1 | 安装nmp阿里的命令: |
2.安装git
首先查看电脑是否安装Git,终端输入1
git
查看是否出现下图内容:
安装git:1
brew install git
如果之前未安装homebrew,需安装homebrew,在终端输入:1
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
3.安装hexo
1 | sudo su 进入root用户,执行下列命令安装: |
4.搭建hexo
1 | hexo init blog //初始化 |
5.部署到GitHub
创建一个xxx.github.io的public仓库
安装一个Git的插件:
1
cnpm install --save hexo-deployer-git
修改站点配置文件(_config.yml),修改 depoly :
1
2
3
4deploy:
type: git
repo: https://github.com/chenyawei1227/chenyawei1227.github.io.git <所建仓库地址>
branch: master1
2
3
4
5
6
7
8
9修改主题后启动如果报如下错误:
extends includes/layout.pug block content include includes/recent-posts.pug include includes/partial
则执行如下命令可解决:
npm install --save hexo-renderer-jade hexo-generator-feed hexo-generator-sitemap hexo-browsersync hexo-generator-archive
hexo clean
hexo deploy部署
1
2
3
4
5hexo clean //清理
hexo g //生产页面
hexo d //部署到GitHub
浏览器访问:https://chenyawei1227.github.io 查看到效果。
6.更改主题
hexo的主题很多,官网的主题:https://hexo.io/themes/
这里以Cxo主题为例:1
2
3
4
5
6
7
8
9
10
11#进入到themes文件夹下,下载主题:
git clone https://github.com/Longlongyu/hexo-theme-Cxo Cxo
# 修改 _config.yml 配置
theme: Cxo
执行:
hexo clean
hexo deploy
浏览器访问:https://chenyawei.github1227.io 查看到效果。
7.创建新文章
1 | hexo new '文章名' |
常用指令:
1 | npm install hexo-cli -g |
If you like this blog or find it useful for you, you are welcome to comment on it. You are also welcome to share this blog, so that more people can participate in it. If the images used in the blog infringe your copyright, please contact the author to delete them. Thank you !