隨意雜記 (Casual Notes)

Apr 26, 2015

Octopress on Windows

Environment

Windows 7

Pre-requisite

  • This article is to setup my Windows 7 environment to write blog posts
  • Use octopress environment pushed by MacOS
  • You have python 2.7 installed on your Windows 7
  • Remaining taks on Windows 7:
  • Install RubyInstaller
  • Clone git repository :octocat:
  • Configure and continue the post

Configure environment

STEP 1: Install RubyInstaller

  • Download and install rubyinstaller.exe

    rubyinstaller

    I picked up ruby-2.1.4(x64) to install

    2.1.4(x64)

STEP 2: Install Ruby Development Kit

  • Download and install DevKit-mingw64-64-4.7.2-20130224-1432-sfx

I installed Ruby 2.1.4(x64), so the development kit I have to use is:

For use with Ruby 2.0 and 2.1 (x64 - 64bits only)

I extract to C:\Ruby21-Devkit where my ruby was installed under C:\Ruby21-x64

STEP 3: Create ruby config.yml

  • Open your windows terminal
1
2
3
   > cd C:\Ruby21-Devkit    
   > ruby dk.rb init
   # This will generate a config.yml
  • Edit config.yml to add where you install the ruby
1
2
    ---
    - C:/Ruby21-x64
  • Install it
1
    > ruby dk.rb install

STEP 4: Update gem

  • Run the following command:
1
    > gem update --system

Then, you will see the following messages:

1
    SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed
  • Solve the SSL issue
1
2
    # To get what gem version you have installed
   > gem --version

1) Download RubyGems based on the gem version you have installed.

Picked up 2.2.x due to my system reports 2.2.2
* 2.2.x

Others:
* 1.8.x
* 2.0.x

2) Run the following commands:

1
2
3
    C:\>gem install --local C:\rubygems-update-1.8.30.gem
    C:\>update_rubygems --no-ri --no-rdoc
    C:\>gem uninstall rubygems-update -x

Congratulations!

3) Now, let’s update gem

1
     gem update --system

Reference link:

STEP 5: Clone your git repository

  • Please git clone your “source” branch not “master” branch
    You can configure your github page using “source” as the default branch
1
2
3
4
    > git clone https://github.com/rickhau/rickhau.github.io.git
    > cd rickhau.github.io
    > gem install bundler
    > bundle install
  • Preview your existing posts
1
    > rake preview

Go to http://localhost:4000 to browse your old posts

STEP 6: Write your new post

1
    > rake new_post["Your new post title"]

Go to source\_posts\ directory to edit your new markdown file for new article.

STEP 7: Configure the UTF-8 encoding

1
2
    set LC_ALL=zh_TW.UTF-8
    set LANG=zh_TW.UTF-8
  • Or you can write it in the .bat script to help you set the encoding automatically
1
2
3
4
5
    @echo off
    set LC_ALL=zh_TW.UTF-8
    set LANG=zh_TW.UTF-8
    rake generate
    rake preview

HAPPY WRITING!!!!