Part 1: Using Github Pages and Hexo to manage personal blogs.
SeriesPart 1: Using Github Pages and Hexo to manage personal blogs on Ubuntu.
Part 2: Using Github Pages and Hexo to manage personal blogs on windows.
Hexo TutorialGithub recommends us to use Jekyll to manage static pages, which is based on Ruby and is difficult for us to install and configure. So we use Hexo instead. Hexo is a static blog framework similar to Jekyll ,which is based on Node.js and easier for use to use.
use Github to create repocreate a new repo in github, name by username.github.io: kezunlin.github.io
Setting | Automatic Page Generator, choose a theame and deploy.
install by apt-get sudo apt-get -y install nodejs sudo apt-get -y install nodejs-legacy sudo apt-get -y install npm node -v npm -v## install nodejs from source
# download and compile wget https://nodejs.org/dist/v8.9.3/node-v8.9.3.tar.gz tar xzvf node-v8.9.3.tar.gz cd node-v8.9.3 ./configure make -j8 sudo make install # link to /usr/bin sudo ln -s /usr/local/bin/node /usr/bin/node sudo ln -s /usr/local/bin/npm /usr/bin/npm # check version node -v npm -v## test node
cat hello.js console.log('Hello World'); node hello.js Hello World install hexo # install hexo globally sudo npm install hexo-cli -g #sudo npm install hexo --save # use cnpm from taobao instead of offical npm, which is slow for chinese users. sudo npm install -g cnpm --registry=https://registry.npm.taobao.orguse cnpm instead of npm (optional)
# cnpm install sudo cnpm install hexo-cli -g # check version hexo -v create hexo site cd workspace mkdir blog cd blog hexo init #npm install hexo generate hexo servernow we can visit localhost:4000 and create posts.
deploy to githubvim blog/_config.yml
deploy: type: git repo: git@github.com:kezunlin/kezunlin.github.io.git branch: mastergenerate ssh-key and copy to github
# generate ssh-key cd ~ ssh-keygen cat .ssh/id_rsa.pub # copy content to github # https://github.com/settings/keys # install plungin and deploy to github npm install hexo-deployer-git --save hexo deploynow we can visit https://kezunlin.github.io/
add README and skip renderadd README.md to source folder
edit blog/_config.yml to skip render README.md
skip_render: - README.mduse hexo generate to copy README.md from source/ to public/
new post and deploy again hexo new 'first post' vim source/_posts/first-post.md hexo generate hexo server hexo deploynow we can visit https://kezunlin.github.io/ and see our first post.
Appendix Hexo commandsHexo common commands:
hexo new "postName" #new post hexo new page "pageName" #new page hexo generate #generate static files to public/ hexo server #start server on localhost:4000 hexo deploy #push .deploy_git/ to GitHub hexo clean #clean filesHexo short commands:
hexo n == hexo new hexo g == hexo generate hexo s == hexo server hexo d == hexo deployHexo composite commands:
hexo server -g hexo deploy -g Post content header template --- title: Using Github Pages and Hexo to manage personal blogs date: 2017-12-26 17:28:10 categories: tutorial tags: - github pages - hexo - nodejs - npm --- more to control web display <!--more--> Use static blog framework Hexo to manage site ----------------------------------------------- Use next theme cd blog git clone https://github.com/iissnan/hexo-theme-next themes/nextvim blog/_config.yml
#theme: landscape theme: next Avataredit blog\themes\next\_config.yml
avatar: /images/avatar.jpg Pluginsinstall plugin by
npm install <plugin-name> --save hexo admin cnpm install --save hexo-adminnow we can visit :4000/admin/
git deployer npm install hexo-deployer-git --save hexo deploy rss feed npm install hexo-generator-feed --save # visit :4000/atom.xml sitemap npm install hexo-generator-sitemap --savevim blog/_config.yml
sitemap: path: sitemap.xmlnow we can visit :4000/sitemap.xml
baidu sitemap npm install hexo-generator-baidu-sitemap --savevim blog/_config.yml
baidusitemap: path: baidusitemap.xmlnow we can visit :4000/baidusitemap.xml
perment link cnpm install hexo-abbrlink --saveedit blog\_config.yml
permalink: post/:abbrlink/ abbrlink: alg: crc32 # crc16(default) and crc32 rep: hex # dec(default) and hexwill fill abbrlink in your post.md
--- title: Hello World categories: - tutorial tags: - hexo abbrlink: 4a17b156 date: 2017-12-26 17:20:10 --- index/archive/category/tag npm install hexo-generator-index --save npm install hexo-generator-archive --save npm install hexo-generator-category --save npm install hexo-generator-tag --save tags list page hexo new page "tags" # generate source/tags/index.mdedit source/tags/index.md
--- title: tags date: 2017-12-27 15:46:09 type: "tags" ---now we can visit :4000/tags/
categories list page hexo new page "categories" # generate source/categories/index.mdedit source/categories/index.md
--- title: categories date: 2017-12-27 15:46:03 type: "categories" ---now we can visit :4000/categories/
local searchinstall search plugin
cnpm install hexo-generator-search --save cnpm install hexo-generator-searchdb --save