經過網絡幾篇文章整理的大體全面的教程。html
確保安裝了git
和ruby1.9.3
,經過brew
安裝rbenv
而後用rbenv
安裝ruby
。git
先卸載MacPortsgithub
sudo prot -f uninstall installed sudo rm -fr \
再安裝brewshell
curl -L http://github.com/mxcl/homebrew/tarball/master | tar xz –strip 1 -C /usr/local export PATH=/usr/local/bin:$PATH
安裝成功後經過brew install
查看brew版本ubuntu
brew install rbenv brew install ruby-build rbenv install 1.9.3-p0 rbenv rehash
git clone git://github.com/imathis/octopress.git octopress cd octopress gem install bundler rbenv rehash bundle install rake install
編輯 config.yml
文件的url
,title
,subtitle
,author
。瀏覽器
最好把裏面的twitter相關的信息所有刪掉,不然因爲GFW的緣由,將會形成頁面load很慢。同理,修改定製文件/source/_includes/custom/head.html 把google的自定義字體去掉。sass
我如今用的就是greyshade主題 http://www.sgxiang.comruby
cd octopress git clone git@github.com:allenhsu/greyshade.git .themes/greyshade echo "\$greyshade: color;" >> sass/custom/_colors.scss //替換 color 爲自定義的連接高亮顏色 rake "install[greyshade]"
在_config.yml中加入markdown
weibo_user: xsxiang # 微博數字 ID 或域名 ID dribbble_user: weibo_share: true # 是否開啓微博分享按鈕
關於greyshade主題的頭像問題,有兩種途徑能夠設置頭像
Disqus是octopress內置的comments功能,編輯config.yml
文件能夠打開該功能,找到如下內容修改
#Disqus comments disqus_short_name: disqus_show_comment_count: false
填入註冊disqus帳號的名稱,並將false修改成true。【disqus要和本身的username.github.com關聯上】
cd ~/.ssh ssh-keygen -t rsa -C 你註冊github時的email
彈出Enter file in which to save the key (/Users/twer/.ssh/id_rsa):
直接按空格
彈出Enter passphrase (empty for no passphrase):
輸入你github帳號的密碼。Enter same passphrase again:
再次輸入你的密碼。
打開~/.ssh下的id_rsa.pub文件複製裏面的所有內容。
登錄github,選擇Account Settings-->SSH Public Keys 添加ssh,把剪切板的內容複製到key輸入框內直接保存。
測試shh:
ssh git@github.com
輸出
PTY allocation request failed on channel 0 Hi username! You've successfully authenticated, but GitHub does not provide shell access. Connection to github.com closed.
表明成功
登錄github建立一個倉庫 ,倉庫名稱爲username.github.com好比個人是sgxiang.github.com
利用octopress的一個配置rake任務來自動配置上面建立的倉庫:可讓咱們方便的部署GitHub page。在終端輸入以下命令:
rake setup_github_pages
彈出以後輸入git@github.com:your_username/your_username.github.com.git
不要用提示的io,個人是git@github.com/sgxiang/sgxiang.github.com.git
輸入如下命令部署博客
rake generate rake deploy
若是沒法push到倉庫的master分支,嘗試在項目目錄的.git/config中添加
[branch "master"] remote = origin merge = refs/heads/master
博客的source須要單獨提交,執行以下命令就能夠將source提交到倉庫的source分支下
git add . git commit -m 'Initial source commit' git push origin source
部署前能夠在本地預覽,輸入rake preview
以後在瀏覽器輸入http://localhost:4000/
來訪問
經過命令
rake new_post["myTitle"]
文章生成在目錄下的source/_posts
目錄下。文章是markdown格式的。能夠經過 Mou 軟件來編輯保存。
關於markdown的格式能夠參考這篇文章:http://wowubuntu.com/markdown/
寫完後就能夠部署更新文章到github上了
rake generate git add . git commit -am "Some comment here." git push origin source rake deploy
參考文章