Node环境下Hexo的搭建

  1. Enviroment
  2. init your hexo
  3. file tree
  4. Run server
  5. configurate your github
    1. edit your config file
    2. Deploy to remote sites
    3. new article

Enviroment

Node.js and github account

init your hexo

1
2
3
4
5
$ npm install hexo-cli -g
$ hexo version
$ hexo init {yourname}.github.io
$ cd {yourname}.github.io
$ npm install

file tree

1
2
3
4
5
6
7
8
9
10
11
12
$ tree
...... file tree
├── .deploy #需要部署的文件
├── node_modules #Hexo插件
├── public #生成的静态网页文件
├── scaffolds #模板
├── source #博客正文和其他源文件,404、favicon、CNAME 都应该放在这里
| ├── _drafts #草稿
| └── _posts #文章
├── themes #主题
├── _config.yml #全局配置文件
└── package.json #npm 依赖等

Run server

1
2
3
4
5
6
7
8
9
$ npm install hexo-server --save
or
$ yarn add hexo-server && yarn install

$ hexo server
or
$ hexo s
······
http://localhost:4000/

configurate your github

1
2
3
4
5
6
$ git config --global user.name "your-name"
$ git config --global user.email "your-email"

$ npm install hexo-deployer-git --save
or
$ yarn add hexo-deployer-git && yarn install

edit your config file

path:{yourname}.github.io/_config.yml

1
2
3
4
5
6
7
# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repo: git@github.com:{yourname}/{yourname}.github.io.git
## use https repo: https://github.com/{yourname}/{yourname}.github.io.git
branch: master

Deploy to remote sites

1
2
3
4
5
6
$ hexo clean
$ hexo generate
$ hexo deploy
or
$ hexo clean
$ hexo d -g

new article

1
$ hexo new "title"

转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 nathanwriting@126.com

文章标题:Node环境下Hexo的搭建

字数:235

本文作者:Nathaniel

发布时间:2020-10-19, 15:28:59

最后更新:2023-11-06, 22:59:18

原始链接:http://example.com/2020/10/19/hexo-for-node/

版权声明: "署名-非商用-相同方式共享 4.0" 转载请保留原文链接及作者。

×

喜欢就点赞,疼爱就打赏