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

博客的搭建与备份

https://www.jianshu.com/p/9b87aae19093

备份博客

由于博客是在本地生成的,如果更换电脑,那我们是不是就不能用这个博客了?方法总比问题多,我们可以利用github来备份博客的文件和数据。

https://github.com/coneycode/hexo-git-backup

1.安装

1
npm install hexo-git-backup --save

2.在博客配置文件 _config.yml 中添加:

1
2
3
4
5
6
backup: 
type: git
theme: next,...
message: update xxx
repository:
git@github.com:TRHX/TRHX.github.io.git,backup

配置中可以设置提交时的信息(message);

可以指定一起备份的主题(支持多个, 逗号分隔);

repository 也可以指定多个地方进行同步备份;

网上说的比较多的是将备份放到博客项目的一个分支里, 即将上面的 branchName 设置成分支名称, git 路径与博客项目 github用户名.github.io 一致;

3.在命令行中执行

1
hexo backup

如果原先是通过手动方式进行的备份, 即没有使用插件, 此时再用插件备份是会出错的. 解决方法是将博客目录下的 .git 目录删除, 再执行 hexo backup 命令;

原文

https://memento.net.cn/post/b96cbb80.html

解决index.lock 的办法

1
git clean -f .git/index.lock

常用hexo命令

常见命令

1
2
3
4
5
6
7
hexo new "postName" #新建文章
hexo new page "pageName" #新建页面
hexo generate #生成静态页面至public目录
hexo server #开启预览访问端口(默认端口4000,'ctrl + c'关闭server)
hexo deploy #部署到GitHub
hexo help # 查看帮助
hexo version #查看Hexo的版本

缩写:

1
2
3
4
hexo n == hexo new
hexo g == hexo generate
hexo s == hexo server
hexo d == hexo deploy

组合命令:

1
2
hexo s -g #生成并本地预览
hexo d -g #生成并上传

Hexo版本升级

1
2
npm i hexo-cli -g
npm update