Octopress 安裝筆記

其實官方的說明也有,但因為我Xcode的環境不一樣,還是來註記一下!

Octopress Blog環境需求:

  • 要安裝Git
  • 最低要Ruby 1.9.2, 可以透過RVM or rbenv安裝,擇一

我是使用RVM,至於Git的安裝及ssh驗證,可以看看官方說明,很詳細。

####1.首先安裝RVM

1
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

####2.寫入profile到.bash_profile檔案裡

1
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile

####3.裝Ruby,官方說明是安裝1.9.2,但由於我是使用Xcode 4.2, 在裝完RVM時,應該會警告你,建議使用4.1在編譯1.9.2才不會出錯,但我實在不想重裝Xcode, 就只能裝Ruby1.9.3以後的版本,但要注意的是,直接安裝會有non-LLVM問題, 所以使用以下方法安裝

1
rvm install 1.9.3 --with-gcc=clang

####3.1 還有這個動作

1
rvm use 1.9.3

####4.接著就下載Octopress 及 相關軟體

1
2
3
4
5
git clone git://github.com/imathis/octopress.git
cd octopress
gem install bundler
bundle install
rake install

####5.然後在octopress目錄下, 我有幾個地方有設定的:

1
2
3
_config.yml  # blog主要設定配置檔
config.rb # Compass 的設定檔
Rakefile # rake產生及發怖網頁設定檔

####6.建立新文章!
新文章會放在source/_posts,使用markdown檔案方式寫文

1
rake new_post["title"]

####7.部署到Github! 官方說明
我是採用Project pages (gh-pages)的方式,這邊就照作啦~

####8.改一下版型吧!
先到config.rb替sass加上debug的標記,好讓Firebug只知道樣式在那一個檔裡,所有樣式檔都放在sass資料夾下,建議是把要改的樣式寫在sass/custom/_styles.scss裡,因為這個檔是最後載入,可以覆寫之前的樣式,一方面有改版時,只要覆蓋custom資料夾就好.

firebug sass

1
2
sass_options = {:debug_info => true}
line_comments = true

####9.自訂網址
新增CNAME檔案到source下,CNAME檔裡填寫自訂網址,一樣要怖署到Github上

1
echo 'blog.visioncan.com' >> source/CNAME

接著就要到你註冊的網域新增CNAME, 我是在Hostmonster裡設定

1. DNS Zone Editor -> 選擇domain 
2. Add DNS Record
   Host Record: blog
   TTL: 不改
   Type: CNAME
   Points To: visioncan.github.com

等dns生效吧!

附:rake 功能

rake -T

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
rake clean                 # Clean out caches: .pygments-cache, .gist-cache, .sass-cache
rake copydot[source,dest] # copy dot files for deployment
rake deploy # Default deploy task
rake gen_deploy # Generate website and deploy
rake generate # Generate jekyll site
rake install[theme] # Initial setup for Octopress: copies the default theme into the path of Jekyll's generator.
rake integrate # Move all stashed posts back into the posts directory, ready for site generation.
rake isolate[filename] # Move all other posts than the one currently being worked on to a temporary stash location (stash) so regener...
rake list # list tasks
rake new_page[filename] # Create a new page in source/(filename)/index.markdown
rake new_post[title] # Begin a new post in source/_posts
rake preview # preview the site in a web browser
rake push # deploy public directory to github pages
rake rsync # Deploy website via rsync
rake set_root_dir[dir] # Update configurations to support publishing to root or sub directory
rake setup_github_pages # Set up _deploy folder and deploy branch for Github Pages deployment
rake update_source[theme] # Move source to source.old, install source theme updates, replace source/_includes/navigation.html with sourc...
rake update_style[theme] # Move sass to sass.old, install sass theme updates, replace sass/custom with sass.old/custom
rake watch # Watch the site and regenerate when it changes