- https://github.com/ALISURE/hexo_demo
- 该项目有两个分支:
master
和gh-pages
gh-pages
用于部署public
目录中的内容,即静态站点的内容master
是源码,用来生成public
目录中的内容clone
之后npm install
即可
- 该项目有两个分支:
-
安装Git
-
安装Node:https://nodejs.org/dist/
注意版本号,不要太高。建议 https://nodejs.org/dist/v12.10.0/
-
安装hexo
npm install hexo-cli -g
# 帮助
hexo help
# 新建
hexo new file-name
# 本地服务器
hexo s
# 清空
hexo clean
# 生成
hexo g
# 部署
hexo d
-
初始化
hexo init <folder> cd <folder> npm install
-
启动服务器
hexo server
-
访问页面
http://localhost:4000/
_config.yml
deploy
响应命令hexo deploy
,比如部署到Github上index_generator
配置首页url
和root
配置站点的地址和根目录
hexo new [layout] <title>
比如:
hexo new my_page
比如
images
,CSS
,javascript
_data
hexo server # 默认 4000 端口
hexo server -p 5000 # 指定 5000 端口
编写好之后生成,会得到
public
文件夹,可在_config.yml
中配置
hexo g[enerate]
部署到服务器
-
All generated files are saved in the public folder. You can copy them to wherever you like.
-
部署到Github
- 安装插件
npm install hexo-deployer-git --save
- 编辑
_config.yml
deploy: type: git repo: <repository url> branch: [branch] message: [message]
例子:
deploy: type: git repo: https://github.com/ALISURE/hexo_site branch: master
- 生成并部署部署
hexo g[enerate] # 只生成 hexo deploy # 只部署
或者:
hexo generate --deploy # 生成并部署
-
问题:`fatal: could not read Username for 'https://github.com': Invalid argument·
# 解决办法:将https方式改成ssh方式
# 1. 将deploy下的repo更改为下面之一
repo: ssh://git@github.com/ALISURE/alisure.github.io
repo: ssh://git@github.com/ALISURE/alisure.github.io.git
repo: git@github.com:ALISURE/alisure.github.io
repo: git@github.com:ALISURE/alisure.github.io.git
# 2. OK
- 问题:
Host key verification failed. fatal: Could not read from remote repository.
# 解决办法:更改github网站的SSH keys
# 1. 电脑上 git Bash 中输入下列命名,生产keys
ssh-keygen -t rsa -C "562282219@qq.com"
# 2. 将下列文件中的内容复制到hub网站上
/c/Users/ALISURE/.ssh/id_rsa.pub
# 3. OK
-
下载主题,放在
themes
下,例如
git clone https://github.com/klugjo/hexo-theme-anodyne themes/anodyne
- 修改
_config.yml
中的theme
, 例如
# Extensions
## Plugins: http://hexo.io/plugins/
## Themes: http://hexo.io/themes/
theme: anodyne
-
修改其它必要的信息
- 比如修改
themes
中的_config.yml
- 比如修改
-
OVER
Helpers are used in templates to help you insert snippets quickly. Helpers cannot be used in source files.
-
在
languages
中创建xxx.yml
文件 -
在
_config.yml
中配置language: xxx