初次使用Hexo搭建博客

文章发布时间:

最后更新时间:

初次使用Hexo搭建博客

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 安装cli
npm install -g hexo-cli

# 初始化Hexo
hexo init hexo

# 移动到工作目录
cd hexo
# 安装依赖
cnpm install

# Git拉取主题
git clone https://github.com/Yue-plus/hexo-theme-arknights.git themes/arknights

# 生成静态页面
hexo generate


注意事项

如果运行hexo server后浏览器出现 extends includes/layout.pug block content include includes/recent-posts.pug include
页面错误
则需要运行以下命令,并重新生成静态页面hexo generate

1
2
npm install --save hexo-renderer-jade hexo-generator-feed hexo-generator-sitemap hexo-browsersync hexo-generator-archive
hexo clean

部署到阿里云虚拟云主机

虚拟云主机属于FTP上传,需要配置_config.yml文件

1
2
3
4
5
6
7
8
9
deploy:
type: ftpsync
host: <host>
user: <user>
pass: <password>
remote: [remote]
port: [port]
clear: [true|false]
verbose: [true|false]
参数 说明 默认值
host 远程主机的地址
user 远程主机的用户名
pass 远程主机的密码
remote 远程主机的根目录 /htdocs (阿里默认是这个目录)
port 远程主机的端口号 21
clear 在上传前移除远程主机的根目录下所有的文件和目录 false
verbose 显示调试信息 false

配置完成后,运行hexo deploy

参考文献: https://hexo.io/zh-cn/docs/one-command-deployment.html#FTPSync