记录下搭建博客的方法📕~

文档

安装

  • Node.js
  • Git
1
2
//安装Hexo
npm install -g hexo-cli

建站

1
2
3
hexo init <folder>
cd <folder>
npm install

新建完成之后指定文件夹目录如下

1
2
3
4
5
6
7
├── _config.yml //在此文件中配置git仓库,下面会详细介绍
├── package.json
├── scaffolds
├── source
| ├── _drafts
| └── _posts
└── themes

到此站已经建好了,下面去Github上建立自己的仓库吧!🎉🎉🎉🎉

建立仓库

img
img

ps:Repository name必须是 xxx.github.io (xxx是你的github username)

安装必备插件

1
2
npm install hexo-deployer-git
npm install --save hexo-render-pug hexo-generator-archive hexo-generator-tag hexo-generator-index hexo-generator-category

配置仓库

1
2
3
4
5
6
7
8
9
10
11
//_config.yml
deploy:
type: git
repo: 仓库git地址
branch: master

archive_generator:
per_page: 0
yearly: false
monthly: false
daily: false

写博客

1
2
3
4
5
6
//<title>是文章标题
hexo new <title>
//此命令结束后,会在 souce/_posts 下出现对应的文件

//上传静态文件
hexo g -d //hexo generator deployer

完成

浏览https://xxx.githu.io ✌✌✌

安装主题

主题模板

  • 安装主题之前先把默认主题清空

    1
    hexo clean
  • tranquilpeak为例。

img

1
2
3
4
5
6
7
1、Run git clone https://github.com/LouisBarranqueiro/hexo-theme-tranquilpeak.git
2、Rename the folder in tranquilpeak and place it in themes folder of your Hexo blog
3、Modify the theme in _config.yml by changing theme variable to tranquilpeak
4、Complete theme/tranquilpeak/_config.yml with your information by following directives in comments
5、Go in theme/tranquilpeak folder with cd themes/tranquilpeak
6、Install requirements
7、Run npm install to install NPM dependencies