yoshuki43's blog

Octopressインストール方法

Octopressとは

OctopressはJekyllを使ったブログ構築用フレームワーク。 GitHub Pagesと連携できる。

Octopress
http://octopress.org/

インストール
http://octopress.org/docs/setup/

テーマ一覧
https://github.com/imathis/octopress/wiki/3rd-Party-Octopress-Themes

インストール

準備

ruby環境の構築

1
2
3
4
5
sudo apt-get update
sudo apt-get install -y ruby ruby-dev git
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

以下の行を「~/.bash_profile」に追記

1
2
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

反映

1
source ~/.bash_profile

ruby環境を作成(バージョンはここのrubyと同じにするとよい。)

1
2
3
4
 rbenv install 2.4.2
 rbenv global 2.4.2
 gem install bundler
 #rakeは特定バージョンが必要なのでインストールしないこと!rake

node.jsをインストール(ExecJSで必要になるため。)

1
2
curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs

Octopressインストール

1
2
3
4
5
git clone git://github.com/imathis/octopress.git octopress
cd octopress
rbenv rehash
bundle install
rake install

テーマ変更

このへんからよさげなテーマを選ぶ。

https://github.com/imathis/octopress/wiki/3rd-Party-Octopress-Themes

GitHubをDeploy先として登録

1
2
3
4
5
6
7
8
「ユーザ名.github.io」というリポジトリをGitHubに作っておく。

$ rake setup_github_pages
    :
Repository url: https://github.com/<username>/<username>.github.io
    :
$ rake generate
$ rake deploy

https://<username>.github.io/」にアクセスしてみる。

設定

1
vi _config.yml

ブログ以外のファイルも入れたい?
-> sourceフォルダにGitHub Pagesにアップロードしたいファイルを入れる。

ブログを書く

1
2
3
$ rake new_post['1st post']
mkdir -p source/_posts
Creating new post: source/_posts/2018-02-09-1st-post.markdown

ファイルが作成されるので、編集する。

マークダウンヘルプ
https://github.com/higuma/markdown_cheat_sheet
https://help.github.com/articles/basic-writing-and-formatting-syntax

VSCodeを使用していれば、マークダウンを開いた画面の右上にある「プレビューを横に表示」ボタンでプレビュー画面を表示できる。(Ctrk+K vでもOK?)

追記:
VSCodeの拡張機能「Markdown Preview Github Styling」をインストールすれば、よりGitHubに近い形でプレビューを表示できる。

書き終わったら先ほどと同じようにgenerate->deployする。

1
2
rake generate
rake deploy

Comments