參考別人的文章,做了自己的記錄。
1.準備工作
首先你必須要有以下的幾樣?xùn)|西:
git,以及github.com帳號,(我這里將blog放置在github上,沒有就趕緊注冊吧)
ruby的開發(fā)環(huán)境,我這使用的Octopress需要Ruby1.9.2,這些我都有了
2.安裝Octopress
git clone git://github.com/imathis/octopress.git octopress
cd octopress
gem install bundler # 安裝ruby1.9.2下的bundler
bundle install # 安裝依賴的組件
rake install # 安裝默認的Octopress主題
3.配置github
在github上創(chuàng)建一個倉庫,注意倉庫名稱要以下這種格式y(tǒng)ourname.github.io,這樣代碼發(fā)布后自動這個url就可以訪問了。
設(shè)定 GitHub Pages
rake setup_github_pages
中間會有要求輸入用戶名地址之類的,照做就好了。
rake generate
rake deploy
如果發(fā)布失敗,提示版本不同步,可以執(zhí)行以下操作:
octopress$ cd _deploy
_deploy$ git pull https://github.com/weipipi/weipipi.github.io
_deploy$ git push origin master
octopress$ rake deploy
4.將 source 也加入 git
git add .
git commit -m 'initial source commit'
git push origin source
5.更新 Octopress
日后有 Octopress 新版本發(fā)布,使用以下指令升級。
git remote add octopress git://github.com/imathis/octopress.git
git pull octopress master # Get the latest Octopress
bundle install # Keep gems updated
rake update_source # update the template's source
rake update_style # update the template's style
6.發(fā)表新文章
rake new_post["新文章名稱"]
會在“source/_posts”目錄下自動生成“Timestamp-qing-song-an-zhuang-octopress.markdown”,編輯后即可發(fā)布.
rake preview
會在本地啟動sinatra服務(wù),用瀏覽器打開 http://localhost:4000 就可以看到效果了。如果都沒有問題就可以發(fā)布了。
7.發(fā)布
rake gen_deploy
rake deploy #若發(fā)布后無效果可試試此命令
8.配置
- 配置文件為(_config.yml):
按已有的項目改想改的內(nèi)容就可以了。
修改后需要rake generate和rake deploy
-
Jekyll & Plugins
paginate: 10 # 每頁的文章數(shù)量,超過翻頁
recent_posts: 5 # 右側(cè)“最近發(fā)表”的模塊里顯示的文章數(shù)量
excerpt_link: "Read on →" # 在文章中使用,列表頁將不再顯示全文,而是顯示“Read on”的鏈接,指向全文
default_asides: [asides/recent_posts.html, asides/github.html, asides/twitter.html] # 用于配置側(cè)邊欄
為Octopress修改主題和自定義樣式
修改網(wǎng)站背景或者配色后,需要rake generate才能生效