LoginSignup
11
12

More than 5 years have passed since last update.

HexoでGithub Enterpriseの個人ページにブログを書く

Last updated at Posted at 2014-10-24

使っていますか?Github Enterprise

かなり便利ですよね。
そんなわけで、、Github Enterprise内でブログを書こうと思ったわけですよ。
Middlemanとか、jekyllとか、Octopressとか、いろいろあるんですが、
とりあえずHexoを試そうと思って、しかし、所々つまづいたところがあったので
とりあえず書いておこうと思います。

手順

リポジトリを作成する

Github.comに作るのとは少し違います。
例えば、Github Enterpriseのドメインがexample.com、自分のユーザ名がkumaだったとしたら、
kuma/kuma.example.com というリポジトリを作ります。
もしドメイン名なんてねえよ!ッて言う場合は例えば、kuma/kuma.10.0.0.1 という感じで作ります。

Hexoをnpmでインストールをする

nodeとnpmがすでに入っている想定ですが、
npm install -g hexo これだけで完了です。

Hexoでブログを生成する

適当なディレクトリで、hexo init <blog name> 例えば、 hexo init kumablog これだけです!

設定ファイルをいじる

設定ファイルは生成されたディレクトリの _config.yml です。
ここでパスの設定と、デプロイの設定をします。
まずは15行目辺りにある url root をいじります。例えばこんな感じ。

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://<gheのURL>/pages/<ユーザ名>
root: /pages/<ユーザ名>/

上記に出した例だと、

# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: http://example.com/pages/kuma
root: /pages/kuma/

とか。

あとはファイルの後ろのほうにある deploy も編集する。こんなかんじ。

# Deployment
## Docs: http://hexo.io/docs/deployment.html
deploy:
  type: github
  repo: http(s)://<gheのURL>/<ユーザ名>/<さっき作ったリポジトリ名>.git
  branch: master
  message: <メッセージ>

例えば、

# Deployment
## Docs: http://hexo.io/docs/deployment.html
deploy:
  type: github
  repo: https://example.com/kuma/kuma.example.com.git
  branch: master
  message: Hexo deploy

こんな感じ。

デプロイしてみる

ここまで終わったらデプロイしてみる。
デプロイも簡単で、 hexo deploy -g を実行するだけ!
しかし、途中でGHEへのログインが求められるので、ただ単に待ってるだけじゃいつまでたってもデプロイされないので注意!

まとめ

もっとしっかり使っていきたいと思う。
また、例えば会社のエンジニアブログ的なものをやる場合、
GHEをステージング環境、github.comを本番環境、みたいにして使い分けてもいいかもしれない。

11
12
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
11
12