How to build a blog by Hexo
Overview
Recently I want to build a static website since it could host on GitHub Pages. I found Hexo which is written by Node.js. Hexo could let you build your website very fast and it also supports Markdown for writting your webpage.
Installation
Theme
If you want to build your blog easily and quickly, you will need to leverage Hexo theme. Theme is a collection of css, js which could render your webpage.
There are many themes could be selected on Hexo/Theme. Following only two steps could build your website with theme:
- Create a new folder with entire files of theme under
./themes
. - Open
./_config.yml
and update variable oftheme: <theme>
.
Build
- Initialize a website
npx hexo init
- Create a new article
npx hexo new <title>
- Generate static files
npx hexo generate
- Start a server
npx hexo server
Deploy
GitHub Pages
- Install hexo-deployer-git
- Update
./_config.yml
1
2
3
4deploy:
type: git
repo: https://github.com/<username>/<project>
branch: <branch> - Execute
npx hexo clean && npx hexo deploy -g
- Launch <username>.github.io