achilles heel wiki:Hello Octopress!

来源:百度文库 编辑:中财网 时间:2024/05/08 18:56:04

Hello Octopress!

ACSite的空间即将在2012/1/31到期,而我又懒得续约,这时看到愈来愈多部落客都从WordPress转移到Octopress,便开始试用Octopress

OctopressWordPress同样身为部落格系统,却有相当大的不同:

  • WordPress
    • PHP
    • 动态网页
    • 外挂多样
    • 速度慢
    • 使用简单
  • Octopress
    • Ruby
    • 静态网页
    • 刚起步,外挂还很少
    • 速度快
    • geek才会用

以下将简单介绍Octopress的安装与使用。

安装

Ruby

Octopress的安装非常简单,首先你需要准备Ruby的 ??环境,以下以Mac为示范:

请务必照着步骤做。

1.安装Xcode(建议使用4.1版),或直接安装OSX GCC Installer

2.安装Homebrew

$ ruby?? -e "$(curl -fsSL https://raw.github.com/gist/323??731)"$ brew update

3.安装Git

$ brew install git

别忘了Mac上有SourceTreeGitX这两套不错的Git GUI可以使用!

4.安装MySQL

5.安装RVM

$ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)$ echo "[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm" >> ~/.profile $ . ~/.profile$ source ~/.profile

6.安装RubyOctopress要求使用1.9.2版)

$ rvm install 1.9.2$ rvm 1.9.2 --default

若是安装失败的话,请试着使用以下方式安装:

$ rvm remove 1.9.2$ export CC=/usr/bin/gcc-4.2$ brew install readline$ brew link readline$ rvm install 1.9.2 --with-readline-dir=$rvm_path/usr

7.安装Pow

$ curl get.pow.cx | sh

(以上安装步骤参考自我这样安装Rails -佑样の技术笔记

Octopress

到目前为止,只不过安装好Ruby罢了,接着才是重头戏── Octopress登场!

1.安装rbenv

$ brew install rbenv$ brew install ruby??-build

2.下载Octopress

$ git clone git://github.com/imathis/octopress.git octopress$ cd octopress

3.安装相关套件

$ gem install bundler$ rbenv rehash$ bundle install

4.安装预设布景主题

$ rake install

如此一来就安装好Octopress了,你可以输入rake previewlocalhost:4000预览,或是透过Pow预览:

$ cd ~/.pow$ ln -s /path-to-octopress

发布

1.在GitHub建立名为http://yourname.github.com的repository,yourname必须与你的使用者名称相同,否则会建立专案页面。

2.设定GitHub资料,并依照指示输入GitHub页面的repository网址。

$ rake setup_github_pages

3.建立网志资料

$ rake generate

4.发布至GitHub

$ rake deploy

5.建立commit

$ git add .$ git commit -m 'your message'$ git push origin source

过几分钟后GitHub就会寄信通知你专业建立完成,连上yourname.github.com就能见到你的Octopress啰!

若要进一步设定,请编辑Octopress根目录中的_config.yml

自定网域

source/CNAME输入网域名称

$ echo 'your-domain.com' >> source/CNAME

若网域名称如www.example.com,只需要新增CNAME记录yourname.github.com即可;若如example.com,则必须加入A记录207.97.227.245,请勿使用CNAME记录。

(以上安装步骤参考自Octopress Documentation

写作

虽然安装看起来很麻烦,不过写作文章相当简单!

文章

$ rake new_post['title']

输入以上代码后,就可在source/_posts见到yyyy-mm-dd-title.markdown格式的文件,以及以下内容:

---layout: posttitle: "Post Title"date: 2012-01-14 15:52comments: truecategories:---

你可透过以下几种方式来编辑分类:

# 单一分类categories: Sass# 多重分类(1)categories: [CSS3, Sass, Media Queries]# 多重分类(2)categories:- CSS3- Sass- Media Queries

Octopress完整支援Markdown语法,另外可利用达成「详阅全文」的效果。

分页

# 一般分页  $ rake new_page[your-page]# 子分页$ rake new_page[your-page/sub-page.html]

输入以上代码后,就可在source/your-page中见到index.markdown,以及以下内容:

---layout: pagetitle: "Page Title"date: 2012-01-14 15:52comments: truesharing: truefooter: true    ---

操作方法与文章大同小异,同样完整支援Markdown语法。

建立

输入rake generate即可建立文章或分页,输入rake deploy就会将文章pull到GitHub上。

结论

经过这几天的试用结果,老实说Octopress实在有够难用,没有如WordPress的强大管理介面,所有操作(包括新增文章、分页)都必须透过终端;然而撰写文章比WordPress快多了,不需忍耐WordPress慢吞吞的编辑器,在local用Markdown写完就能直接deploy到GitHub上。

如果你是个geek,Octopress或许是不错的选择;如果不是的话,请继续使用WordPress吧!