Current node.js and hexo version information
1 | node -v |
Install Node.js
Install Hexo
啟動command box使用ndoe.js的rpm工具安裝hexo1
npm install hexo -g
測試一下hexo是否安裝成功1
hexo
開個目錄放hexo資料1
2
3
4
5cd \
mkdir hexo
cd hexo
hexo init blog
cd blog
安裝hexo的套件1
2
3
4
5
6
7
8
9
10
11
12
13
14
15npm install -g hexo-cli --save
npm install hexo-server --save
npm install hexo-renderer-ejs --save
npm install hexo-renderer-marked --save
npm install hexo-renderer-stylus --save
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-generator-feed --save
npm install hexo-generator-sitemap --save
npm install hexo-tag-bootstrap --save
安裝終了
試寫文章
1 | hexo new "test new post" |
source/_posts/test-new-post.md會被產生,內容附上post需要的標頭。
試一下hexo產生static web pages的功能。1
hexo g
☹ 如果一篇post都沒有,在hexo g時會發生錯誤。
可以執行hexo自帶的local http server來驗證一下內容。 http://localhost:4000/1
hexo s
Deploy to github
You need to install git deployer. ref: http://hexo.io/docs/deployment.html1
npm install hexo-deployer-git --save
Edit _config.yml to configure git in hexo.1
deploy:
type: git
repository: git@github.com:zhengda/zhengda.github.io.git
branch: master
先在github上建一個名叫zhengda.github.io的新repository讓hexo deploy。
https://zhengda.github.io 也是github所提供對映zhengda.github.io這個repository的二級域名。
產生static web pages然後deploy到github上。1
2hexo g
hexo d
若有買自己的一級域名(ex: xxxx.com)可以設定對映到這個repository空間。
github還讓你能自定404頁面,只要建一個404.html在一級域名下即可。
Change Themes
hexo theme evalutaion on zhihu http://www.zhihu.com/question/24422335
- yilia https://github.com/litten/hexo-theme-yilia http://litten.github.io/2014/08/31/hexo-theme-yilia/
1
git clone https://github.com/litten/hexo-theme-yilia.git themes/yilia
edit /_config.xml to change theme as yilia1
#### theme: landscape
theme: yilia
configure /themes/yilia/_config.yml
重新產生static pages然後deploy1
2hexo g
hexo d
用-g參數可以在deploy前generate,就不用打二次指令了。1
hexo d -g
有時要弄乾淨點時會這樣1
del db.json & hexo clean & hexo d -g
Other themes
next https://github.com/iissnan/hexo-theme-next
1
git clone https://github.com/iissnan/hexo-theme-next themes/next
light https://github.com/hexojs/hexo-theme-light
1
git clone https://github.com/hexojs/hexo-theme-light.git themes/light
strict https://github.com/17/hexo-theme-strict
1
git clone git@github.com:unmric/hexo-theme-strict.git themes/strict
apollo https://github.com/joyceim/hexo-theme-apollo
1
git clone https://github.com/joyceim/hexo-theme-apollo.git themes/apollo
simplest https://github.com/dnxbf321/hexo-theme-simplest
1
2
3git clone https://github.com/dnxbf321/hexo-theme-simplest.git themes/simplest
npm install autoprefixer-core --save-dev
npm install clean-css --save-devcarbon https://github.com/icylogic/carbon
1
2
3git clone https://github.com/icylogic/carbon.git themes/carbon
npm install hexo-renderer-coffeescript --save
npm install hexo-renderer-jade --saveminos https://github.com/ppoffice/hexo-theme-minos
1
git clone https://github.com/ppoffice/hexo-theme-minos.git themes/minos
jacman https://github.com/wuchong/jacman
1
git clone https://github.com/wuchong/jacman.git themes/jacman
ref: http://www.cnblogs.com/liulangmao/p/4323064.html
ref: http://jinyanhuan.github.io/2015/03/12/hexo-build-two/ , http://jinyanhuan.github.io/2015/03/12/hexo-build-three/
More
目前必需自己產生tags/index.md。並在title/date後補上type: “tags”1
hexo new page tags
☹ 大多數theme在處理/tags/index.html時都有問題。目前唯知next theme有處理正確。
rss feed和sitemap必需先裝好generator1
2npm install hexo-generator-feed --save
npm install hexo-generator-sitemap --save
_config.yml1
plugins:
- hexo-generator-feed
- hexo-generator-sitemap
sitemap:
path: sitemap.xml
feed:
type: atom
path: atom.xml
limit: 20
關掉git的crlf置換
內定git會把檔案的LF換成CRLF,造成
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in index.html.
有點煩人,只要下git指令就可以關掉1
git config --global core.autocrlf false
SEO
即使你在hexo中建立了sitemap.xml,google可能還是不會主動index內容。
這時你必需要透過google webmaster central頁面 https://www.google.com/webmasters/verification/home?hl=en
增加網站並為google驗證網頁所有權。
這樣過幾天後,網站頁面就會開始能被google搜尋到。
google analytics
比如說用的theme是minos,只要在themes/minos/_config.yaml裡
原本是空值的google_analytics: 補上google analytics的GAID再下hexo -d g重建網站內容即可。
注意 google_analytics: UA-888888-99 ,:後必需有空格不然會解析yaml失敗。