atijust's blog

技術的なこととか。

GitHub+Octopressでブログ構築

f:id:atijusts:20130304004328p:plain

GitHub+Octopressでブログを構築したときのメモ。

今回はGithub PagesUser& Organization Pagesにブログを設置する。

あらかじめアカウント名.github.comという名前のレポジトリを生成しておく。 サイトのURLはhttp://アカウント名.github.com/になる。 Ruby 1.9.3が必要。

$ git clone https://github.com/imathis/octopress.git atijust.github.com
$ cd atijust.github.com
$ rbenv global 1.9.3-p194
$ gem install bundler
$ rbenv rehash
$ bundle install
$ rake install
$ rake setup_github_pages
Enter the read/write url for your repository: git@github.com:atijust/atijust.github.com.git
$ rake generate
$ rake deploy

rake generate_deploy以下にサイトに公開されるファイルが生成されるようだ。 rake deploy_deployがmasterブランチにpushされ、 http://atijust.github.com/から参照できるようになる。

設定ファイルやポストはsourceブランチで管理するようなので別途pushしておく。

$ git add .
$ git commit -m '最初のコミット'
$ git push -u origin source

設定は_config.ymlで行う。

url: http://atijust.github.com
title: GitHubでブログのテスト
subtitle: Octopressでおためしブログ
author: atijust
simple_search: http://google.com/search
description:

ポストを作成するコマンドが用意されている。

$ rake new_post['octopress-install']
$ vi source/_posts/2013-03-03-octopress-install.markdown

画像ファイルはsource/imagesに月毎にディレクトリを作成して設置することにした。 rake generate_deploy以下にコピーされるので絶対パスで指定。

書き終わったら生成&デプロイ。

$ rake generate
$ rake deploy

ローカルでプレビューもできる。

$ rake preview