GITHUB PAGES

GitHub Pages


GitHub Pages are websites for you and your projects.
Git is used to upload local data to github.
Hexo is an easy-to-use template, source folder in your local hexo folder contains what you need to write.


GitHub Pages

GitHub


You need to sign up first, use your email.

GitHub

New a repository named xxx.github.io, this name is reserved for you.

Git


install Git

Git

If you use windows OS, maybe you need to add git to path by yourself.

add your message to global git

git config --global user.email "xxx"
git config --global user.name "xxx"

SSH


Generate ssh key, git use it to access your github account.
Find ssh-keygen.exe in git/usr/bin, add it to path.

ssh-keygen -t rsa -C "your mailbox"

Edit xxx_rsa.pub in ~/.ssh with notepad, copy it and add it to your github account.

ssh keys

Edit config in ~/.ssh, or new one there.
HostName defines where you upload your data, Host is a nickname, User is your username of github, IdentityFile tells where your rsa file is.

Host        xxx
HostName    github.com 
User        xxx
IdentityFile    ~/.ssh/github_rsa

You can use like that git@Host:User when you deploy, in this tutorial, we use it in hexo’s _config.yml. If you edit the config, the nickname Host must be used rather than HostName.

check ssh to github

ssh git@Host

check for more information

ssh -T -v git@Host

Node.js


Hexo is based on Node.js, so you need to install Node.js first.

Node.js

Change npm to cnpm, Taobao’s npmjs.org is faster to access in china.

npm install -g cnpm --registry=https://registry.npm.taobao.org

Then you can use cnpm instead of npm like that.

cnpm install [name]

Hexo


Hexo is a famous template based on github pages.

install global hexo

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

create a folder for your local data

cd xxx
hexo init
npm install

install plug-in of hexo

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-server --save
npm install hexo-deployer-git --save
npm install hexo-deployer-heroku --save
npm install hexo-deployer-rsync --save
npm install hexo-deployer-openshift --save
npm install hexo-renderer-marked@0.2 --save
npm install hexo-renderer-stylus@0.2 --save
npm install hexo-generator-feed@1 --save
npm install hexo-generator-sitemap@1 --save

check hexo server

hexo server

localhost

use abbr

hexo n # new a post, or add it in xxx/source/_posts by yourself
hexo g # generate 
hexo s # server
hexo d # deploy to github
hexo d -g

edit _config.yml in hexo folder

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
      type: git
      repo: git@xxx:xxx/xxx.github.io.git
      branch: master

Choose a theme, I use NexT.

NexT

localsearch

localsearch

MarkDown

The source file is x.md in xxx/source/_posts, I use MarkdownPad in windows OS.

MarkdownPad

grammar of Markdown

Markdown

Domain

I choose AliYun.

AliYun


Domain

add CNAME in your xxx/source folder
edit CNAME

xxx.xxx # your domain

REFERENCE


  1. 使用GitHub和Hexo搭建免费静态Blog
  2. 20分钟教你使用hexo搭建github博客
  3. Git命令行处理多个Github账户
  4. 淘宝 NPM 镜像
  5. 主题配置 - NexT使用文档
  6. Markdown 语法说明
  7. Hexo之next主题设置首页不显示全文
Chen Zhigao wechat
CONTACT ME!