LoginSignup
2
2

More than 5 years have passed since last update.

GhostをBusterでGithubPagesにホスティングする

Last updated at Posted at 2015-10-30

概要

Ghost を Buster を利用して静的なサイトとして吐き出して Github Pagesでホスティングする手順と運用方法

なぜGhostか

HugoやOctopressなど色々試した結果、最終的にGhostで落ち着きました。

Hugoも導入はラクチンでしたがGhostは管理画面が使いやすいのが決め手でした。

環境

OSX Yosemite 10.10.5

% brew -v
Homebrew 0.9.5
% node -v
v0.10.33
% npm -v
2.1.6

手順

node.jsのインストール

wgetはお好みで。

% brew install node
% brew install wget

Ghostのインストールと起動

% mkdir ghost
% cd ghost
% wget --no-check-certificate https://ghost.org/zip/ghost-0.5.2.zip
% unzip ghost-0.5.2.zip
% npm install --production
% npm start

sqlite3のエラーが出る場合は後述。

Ghostにログイン

http://localhost:2368/ghost でアカウント設定を行い、管理画面へログインできる。

GitHubPagesにレポジトリの作成

  1. GiHubにアクセス
  2. +new repository
  3. username/username.github.ioのレポジトリを作成

Ghostのディレクトリに作成したレポジトリをcloneする

% pwd /Users/username/ghost
% git clone git@github.com:username/username.github.io.git ./static

Busterのインストール

Ghostを静的ページとしてstaticディレクトリ以下に吐き出すためのツールとしてbusterをインストールする。

npm startはそのままにしておきたいので、ターミナルで新しいタブを開いて作業を行う。

% brew install python
% sudo pip install buster

Busterのデプロイ先を設定

% buster setup --gh-repo=git@github.com:username/username.github.io.git static

Ghost Buster !!

Ghostの内容をstatic以下にBusterする。

buster deployコマンドで指定したデプロイ先にpushするまでを行ってくれる。

% pwd /Users/username/ghost
% buster generate --domain=http://localhost:2368
% buster preview  #browse http://localhost:9000
% buster deploy
Good job! Deployed to Github Pages.

確認

生成されたページ

運用方法

staticディレクトリは以外はbitbucketで管理する

% rm -rf static
% git init
% git remote add origin bitbucketの管理用リポジトリ
% git add -A
% git commit -m 'add'
% git push -u origin master

staticディレクトリをsubmoduleとして管理する

% pwd /Users/username/ghost
% git clone git@github.com:username/username.github.io.git static
% cd static
% git submodule init
% git submodule update

新規記事投稿

ここまで設定すればあとは以下の手順で記事作成公開できる。

% npm start
管理画面 http://localhost:2368/ghost へアクセスして記事投稿

% buster generate --domain=http://localhost:2368
% buster deploy

sqlite3まわりでエラーが出る場合

npm start時に以下のエラーが出てsqlite3のモジュールが見つからないよと言われる場合。再インストールすると上手くいきました。

Ghost Troubleshooting Guide

ERROR: Cannot find module '/Users/satoshin2071/ghost/node_modules/sqlite3/lib/binding/node-v14-darwin-x64/node_sqlite3.node'


% cd node_modules
% rm -rf ./sqlite3
% npm install sqlite3 --build-from-source
もしくは
% npm install https://github.com/mapbox/node-sqlite3/tarball/master
% npm cache clean

nodeのヴァージョンが違うとき

Migrations: Up to date at version 003

ERROR: Unsupported version of Node
Ghost needs Node version ~0.10.0 you are using version 0.12.2
Please go to http://nodejs.org to get a supported version

Package.jsonを修正します。

% vim package.json

"engines": {
        "node": "~0.10.0"
    },

↓

"engines": {
        "node": "~0.12.2"
    },

% npm start

> ghost@0.5.2 start /Users/satoshin2071/ghost
> node index

Migrations: Up to date at version 003
Ghost is running in development...
Listening on 127.0.0.1:2368
Url configured as: http://localhost:2368
Ctrl+C to shut down

いけました。

参考

Setup Ghost for GitHub Pages

(RE)STARTING A BLOG WITH GHOST

Git Submoduleの基礎

Running and Installing Ghost on Node 0.12.0

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2