使用hexo, github搭建个人博客

作者 Lu Liang 日期 2018-09-28
使用hexo, github搭建个人博客

This is my first post with Hexo/Github. Welcome to the new world! I hope you can easily get your owned blog ready with this post.

Welcome to Hexo! To 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.

Install and setup hexo for your blog

搭建系统使用的 npm, node, git 版本信息。

➜  hexo git --version
git version 2.10.2
➜ hexo npm -v
5.4.2
➜ hexo node -v
v8.8.1
➜ hexo

Install hexo and hexo-cli

全局安装hexo和hexo-cli

npm install -g hexo
npm install -g hexo-cli

Initial your blog with hexo

使用hexo初始化博客系统

cd hexo
hexo init

Install hexo plugins

Hexo 支持众多的插件。具体设置可以参考Hexo Deployment

# install plugin for deployment

npm install hexo-deployer-git --save
npm install hexo-deployer-ftpsync --save
npm install hexo-deployer-openshift --save
npm install hexo-deployer-rsync --save
npm install hexo-deployer-heroku --save

# install plugin for render

npm install hexo-renderer-marked --save
npm install hexo-renderer-stylus --save

# install plugin for generator
npm install hexo-generator-index --save
npm install hexo-generator-archive --save
npm install hexo-generator-category --save
npm install hexo-generator-tag --save
npm install hexo-generator-feed --save
npm install hexo-generator-sitemap --save

# install server module
npm install hexo-server --save

npm install
# the fix in the issue https://github.com/hexojs/hexo/issues/2682

Install theme and enable it

Hexo缺省的主题是landscape。这里我们安装使用了另外一个主题Anisina。

git clone https://github.com/Haojen/hexo-theme-Anisina.git themes/Anisina
cp ./themes/Anisina/_config.yml .

Generate static documents and start local server to preview them.

hexo g
hexo s

Deploy to github

hexo d

Hexo short commands

hexo s == hexo server
hexo g == hexo generate
hexo d == hexo deploy
hexo n == hexo new

Quick Start

Create a new post

$ hexo new "My New Post"

More info: Writing

Run server

$ hexo server

More info: Server

Generate static files

$ hexo generate

More info: Generating

Deploy to remote sites

$ hexo deploy

More info: Deployment

Refer to: