すべての出会いが美しいとは限らない。すべての別れが悲しいとは言えない。

0%

【Hexo】Part 1. How to Setup Blog with Hexo and NexT on GitHub Pages

Quick Start

This article simply talks about how to setup blog with Hexo and NexT and deploy it to GitHub Pages.

Install Node.js & npm with Homebrew

1
brew install node

Install Hexo

1
npm install -g hexo-cli

Create New Project

1
2
3
$ hexo init blog
INFO Copying data to ~/Documents/blog
INFO You are almost done! Don't forget to run 'npm install' before you start blogging with Hexo!

Following the instruction,run npm install

1
2
cd blog
npm install

Setup Theme - NexT

1
2
cd blog
git submodule add https://github.com/theme-next/hexo-theme-next themes/next

It is a little different from official document. It will be helpful in the next step(【Hexo】2. How to Deploy Hexo Project with Github Actions).

Change the theme in ./config.yml to next.

1
theme: next

Start Server on Local

1
hexo clean && hexo g && hexo s

Deployment

Create a repository on GitHub with the name of {USERNAME}.github.io:

GitHub

Install the plugin of deployment:

1
npm install hexo-deployer-git --save

Add the config of deployment in ./_config.yml

1
2
3
4
5
6
# Deployment
## Docs: http://hexo.io/docs/deployment.html
deploy:
type: github
repo: git@github.com:xxxx/xxxx.github.io.git
branch: master

Excute the command of deployment:

1
hexo deploy -g

Now you can access to your own blog by https://{USERNAME}.github.io.

Others

1
npm install hexo-abbrlink --save
1
2
Plugins:
- hexo-abbrlink
  • Sitemap
1
2
npm install hexo-generator-sitemap --save
npm install hexo-generator-baidu-sitemap --save
1
2
3
4
5
6
7
8
9
10
# Extensions
Plugins:
- hexo-generator-sitemap
- hexo-generator-baidu-sitemap

#sitemap
sitemap:
path: sitemap.xml
baidusitemap:
path: baidusitemap.xml
  • Feed
1
npm install hexo-generator-feed --save
1
2
3
4
5
6
7
8
9
# Extensions
Plugins:
- hexo-generator-feed

#Feed Atom
feed:
type: atom
path: atom.xml
limit: 20

Add robots.txt in source folder

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# hexo robots.txt
User-agent: *
Allow: /
Allow: /archives/

Disallow: /vendors/
Disallow: /js/
Disallow: /css/
Disallow: /fonts/
Disallow: /vendors/
Disallow: /fancybox/

Sitemap: https://{USERNAME}.github.io/sitemap.xml
Sitemap: https://{USERNAME}.github.io/baidusitemap.xml

Comman commands

1
2
hexo new "postName" # Next Post
hexo new page "pageName" #New Page