hexo + githubページでブログ構築
hexoとgithubページでブログを構築したので,手順をメモ。
githubページに公開するときに少し迷ったので,その点を重点的に。
目次
- 環境
- Hexoをインストール
- blogの作成
- github に Github Pagesのリポジトリを作成
- SSH公開鍵の登録
- フォルダをgithub上のリポジトリに紐付け
- ファイルをアップロード
- Hexo コマンド
環境
- Windows8.1
- node.js v0.10.33
- npm v1.4.28.
- hexo v2.8.3
Windows8.1にnode.jsをインストールして環境を構築。
その後hexoをコマンドプロプントでインストール。
Hexoをインストール
コマンドプロプントもしくはGitBashで,下記コマンドを実行
1 | $ npm install -g hexo |
これで,hexoの環境ができあがる。
1 | $ hexo -v |
で,バージョンが表示されれば成功
blogの作成
コンソールでblogを作りたいフォルダに移動して,以下のコマンドを実行
1 | $ hexo init BLOGNAME |
これで,BLOGNAMEというフォルダができるので移動
1 | $ cd BLOGNAME |
これでブログが作成されたので,ローカルサーバーを立ち上げ確認
1 | $ hexo server |
で立ち上げ,http://localhost:4000で確認
github に Github Pagesのリポジトリを作成
new repositoryから,Repository nameを「username.github.io」にして作成。
usernameを一致させないと,失敗するっぽい。
SSH公開鍵の登録
SSHキーを作成して,ローカルとgithubアカウントを紐付ける。
コンソールで作っていくが,GitBashで作った方がうまくいくみたい。
コマンドは以下の通り
1 | $ cd ~/.ssh |
途中でパスワードを設定するか聞かれるが,特に設定したくない場合は空白のままenter。
.sshフォルダにid_rsaとid_rsa.pubというファイルがあれば成功。
id_rsa.pubが公開鍵になるので,メモ帳などで開いて内容をコピー。
Account settings > SSH keys > Add SSH key で先程コピーした内容を貼付け。
登録成功の画面が現われたら登録完了
フォルダをgithub上のリポジトリに紐付け
ローカルのblogフォルダとGithbuPagesリポジトリと紐付けるため以下のコマンドを実行
1 | $ touch README.md |
ファイルをアップロード
下記のコマンドを実行して,ファイルをアップロード
1 | $ git add . |
成功すれば,http://username.github.ioに公開されているはず。
Hexo コマンド
1 | Commands: |