Introduction
This articles will show you how to setup a blog with Hexo, a blog framework built with Node.js, and publish it to GitHub.
Setting up Hexo and host it in GitHub
Dependencies
- Node.js https://nodejs.org
- Git Bash https://git-scm.com or others git tools available online
Install Hexo
Install Hexo, run the following command in git-bash
1
2cd /your hexo directory/
npm install hexo-cli -gmake sure you included the npm directory in your
PATH
variable;C:\Program Files\nodejs\node_modules\npm
Once Hexo is installed, initialize Hexo
1
$ hexo init
following files will be created
. ├── _config.yml ├── package.json ├── scaffolds ├── source | ├── _drafts | └── _posts └── themes
The site is then ready for deploy
Start Hexo in local environment
After installing Hexo, you might want to have a look of the website, you can run the following command
1
$ hexo server
Server will be started and it can be accessed by using
http://localhost:4000
Generate static files
- Generating static files with the following command
1
$ hexo generate
Deploy to GitHub Pages
create a new github repository with name
(you github username).github.io
update global setting of hexo
_config.yml
1
2
3deploy:
type: git
repo: link to your github repositoryThen run the following command to deploy your Hexo site to gitHub
1
$ hexo deploy
you will be able you visit the site with
http://(you github username).github.io
Usage
Adding a new post
Run the following command
1
$ hexo new post "My First Blog Post"
start blogging by editing the newly created markdown file in
<Hexo directory>/source/_posts
regenerate the static files
deploy the changes to remote server if needed
Deleting an existing post
- remove the unwanted post in
<Hexo directory>/source/_posts
References
- Hexo http://hexo.io
- GitHub Pages https://pages.github.com