LoginSignup
5
6

More than 5 years have passed since last update.

hexoとやらを試してみた

Posted at

hexo

githubのアカウントあれば誰でもブログを公開できるとのことです
ということで試してみました

まずはリポジトリ作成

[username].github.io
というリポジトリを作成

hexoの準備

公式通りに
hexoをグローバルにインストール

# npm install hexo-cli -g

以下のコマンドでディレクトリを作成します

# hexo init blog

作成されたディレクトリに移動して、モジュールをインストールします

# cd blog
# npm install

インストールできたら、以下のコマンドで起動します

# hexo server

http://localhost:4000/ にアクセスすると雛形ができてます
簡単ですね

githubで公開

作成されたディレクトリ配下にある_config.ymlを弄ります
_config.ymlではサイトのタイトル等を変更することができます

_config.yml
deploy:
  type: git
  repo: https://github.com/[username]/[username].github.io.git
  branch: master

編集したら、以下のコマンドでデプロイ

hexo deploy -g

エラーがでました。
どうやら、hexo-deployer-gitというモジュールをインストールしないといけないようです。ってことでインストール

npm install hexo-deployer-git --save

改めてデプロイ

hexo deploy -g

https:[username].github.io/にアクセスすると先程http://localhost:4000/でみたページにアクセス出来ます
※ちなみに反映にそれなりに時間が掛かります

テーマの導入

こちらのサイトから気に入ったプラグインcloneします

例えば、こちらなら
https://github.com/mkkhedawat/clexy:embed:cite
READMEにあるようにコマンドを実行します

# git clone https://github.com/mkkhedawat/clexy themes/clexy
# git clone https://github.com/mkkhedawat/clexy themes/clexy
# yarn remove hexo-renderer-ejs
# yarn add hexo-renderer-jade
# yarn add hexo-prism-plugin

_config.ymlを編集

_config.yml
prism_plugin:
  mode: 'preprocess'    # realtime/preprocess
  theme: 'default'
  line_number: false    # default false
theme: clexy

デプロイ

hexo deploy -g

記事の投稿

以下のコマンドを実行

# hexo new post 新規ページ

source/post/新規ページ.mdが作成されているので弄ってpushすれば記事が投稿できます

以上です。

ところで、hexoってなんて読むんですかね・・・?

5
6
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
5
6