Featured image of post HexoでGithubにブログを作る2 GitHubにデプロイする編

HexoでGithubにブログを作る2 GitHubにデプロイする編

Hexoを使ってGithub Pagesにブログを公開します。

GitHub Pages:http://mamichin.github.io ブログ公開場所:https://github.com/mamichin/mamichin.lifeblog

もう1年前の事でしょうか。google Homeアプリ作ってみようと勉強会に参加したときに「デプロイ」という言葉を初めて知りました。グーグル先生に「デプロイとは」と入れて調べたところ、「展開」という意味だそうな。。え?リリースとかじゃダメ?なんか微妙にちょっと違うだけじゃない?なんか、「ホットケーキ」を「パンケーキ」と呼ぶようになったのと同じ感覚。。

まぁいいんですけど~。

前提

HexoでGithubにブログを作る1 ローカルでHexoのWebページ準備編済み

GitHubにリポジトリ作成し、ソースコミット

GitHubにブログ用のリポジトリ(mamichin/mamichin.lifeblog)を作ります。 以下を実施して、gitにソースをmasterにコミットします。

1
2
3
4
5
git init
git add .
git commit -m "first commit"
git remote add origin https://github.com/mamichin/mamichin.lifeblog.git
git push -u origin master

pusu時にGithubのアカウント名やパスワードが聞かれた場合があります。

config.ymlのDeployment書き換え

mamichin.blog直下にある_config.ymlファイルの以下を書き換えます。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: https://mamichin.github.io/mamichin.lifeblog
root: /mamichin.lifeblog/

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: git
repo: https://github.com/mamichin/mamichin.lifeblog.git
branch: master

git デプロイ

Hexoの git デプロイプラグインをインストールします。

1
npm install hexo-deployer-git --save

公開用ファイルを作成(generate)し、デプロイ(deploy)します。

1
2
hexo generate
hexo deploy

まとめてできます

1
hexo deploy -g

git デプロイでエラー

こんなエラーが出ました。

1
2
Host key verification failed.
fatal: Could not read from remote repository.

こちらのサイトを参考に設定して解決です。 gitHubでssh接続する手順公開鍵・秘密鍵の生成から

結局

とてもお手軽にブログが作れるのは良いのですが、デザインとか細かいところが気に始めると、、私の性分には合わないようです。でもいろいろ勉強させてもらいました。

Licensed under CC BY-NC-SA 4.0
Hugo で構築されています。
テーマ StackJimmy によって設計されています。