1+1=10

记记笔记,放松一下...

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.

1
2
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:

1
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:

1
2
3
ruby dk.rb init
ruby dk.rb install
gem install rdiscount --platform=ruby

Set environment variable

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

Install octopress

Download the octopress

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

Install some stuff.

1
2
3
$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

1
2
<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

1
$rake new_post["My first blog"]

Then

1
2
$rake generate
$rake preview

Deploy

Create a repository called username.github.com

Run

1
$rake setup_github_pages

Produce HTML and Deploy it.

1
2
$rake generate
$rake deploy

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

1
2
3
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

1
blog.debao.me

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

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

Redirect?

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

1
2
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
    <!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

1
debao.me

Push above files to gh-pages branch.

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

1
2
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

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

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

First, _config.yml file:

1
2
3
permalink:/:year/:month/:title/
category_dir: categories
pagination_dir:

Second, source/_include/custon/navigation.html

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

And source/index.html

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

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

Reference