1+1=10

扬长避短 vs 取长补短

"Setup and Configure My Octopress Blog"

I am using Mac OS X 10.8, Ubuntu 12.10 and Windows Vista at present. I want to have a simple blog which can be coutrolled by myself …

Install Ruby 1.9.3

Octopress depends on Ruby 1.9.2 or newer.

Mac X 10.8

The Ruby provided by mac is 1.8.7, so we need to install the latest one by ourself.

The missing package manager for OS X - Homebrew, provides ruby 1.9.3.

$ruby <(curl -fsSk https://raw.github.com/mxcl/homebrew/go)
$brew update
$brew install ruby ruby-build rbenv

Edit ~/.bash_login and add following line:

export PATH=/usr/local/Cellar/ruby/1.9.3-p194/bin:$PATH

Ubuntu 12.10

Nothing special, apt-get is enough.

Windows

Download RubyInstaller and DevKit, then install them.

"Start Command Prompt with Ruby", and changed to the directory where DevKit extracted, and run:

ruby dk.rb init
ruby dk.rb install
gem install rdiscount --platform=ruby

Set environment variable

set LANG=zh_CN.UTF-8
set LC_ALL=zh_CN.UTF-8

Install octopress

Download the octopress

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

Install some stuff.

$gem install bundler
$bindle install
$rake install

Configure octopress

  • Open _config.yml, then edit

url, title, subtitle, and author

  • Open source/_include/custom/head.html,

then comment

<link href="http://fonts.googleapis.com/..."
<link href="http://fonts.googleapis.com/..."

As they has been blocked in China, which make the blog take too long time to load.

Write and View Blog

To add a new post

$rake new_post["My first blog"]

Then

$rake generate
$rake preview

Deploy

Create a repository called username.github.com

Run

$rake setup_github_pages

Produce HTML and Deploy it.

$rake generate
$rake deploy

Push source to the source branch, or other private place.

git add .
git commit -a -m 'comment'
git push origin source

Custom Domain

I want to use blog.debao.me for my pages. So create a file called CNAME under source directory. Then put the subdomain into the file

blog.debao.me

Next, I need to setup my DNS. Add a CNAME record pointing to the pages is enough.

blog.debao.me IN CNAME xxxxxx.github.com

Redirect?

At present, I hope that following two domains can be redirected to the pages too.

debao.me
www.debao.me

This is very easy, isn't it?

Though many Sponsoring Registrars such as godaddy have provided such function for us. But it doesn't work in China.

So I need to create another site, then let such too domains point to it.

Project pages provided by github can be used in such cases. What we need is a index.html file, such as

html index.html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>1+1=2</title> <meta http-equiv="REFRESH" content="0;url=http://blog.debao.me/"> </head> <body> Please visit <a herf="http://blog.debao.me">http://blog.debao.me</a> ... . </body> </html>

Then, create a CNAME file

debao.me

Push above files to gh-pages branch.

Next, I need to setup my DNS. Add two A records pointing to the pages.

debao.me IN A 204.232.175.78
www.debao.me IN A 204.232.175.78

Note that, github will automaticly generate redirect from www.xxxx.me to xxxx.me for us.

Remove blog from url path

The urls of my blog look like this

http://blog.debao.me/blog/...

which seems not good. So I want to move evertything to the root directory.

First, _config.yml file:

permalink:/:year/:month/:title/
category_dir: categories
pagination_dir:

Second, source/_include/custon/navigation.html

<li><a href="{{ root_url }}/archives""> Archives</a></li>

And source/index.html

<a href="/archives"> Blog Archives</a>

Finally, Move archives from directory source/blog to source.

Reference

tools

Comments