Hexo ブログ公開まで(2/3) ~ローカル環境でHexoブログ作成~

Hexo ブログ公開まで(2/3) ~ローカル環境でHexoブログ作成~

ローカル環境でブログを作る

前回準備したHexo環境でブログを作成。

前回↓

オフライン環境で実験。

1. Visual Studio Codeで実験準備

Visual Studio Codeを使わないのであれば不要。

Visual Studio Codeを起動。
「Open folder…」から前回作った「test」フォルダを開く。



上の「Terminal」から「New Terminal」を開く。



デフォルトのターミナルは「PowerShell」。
「Command Prompt」に変更。


2. 記事作成

ターミナルに

1
hexo new post postname

と打つと、
source/_posts/postname.mdというファイルが作られる。
これがブログ記事ファイル。
↓最初の中身はこんなの

1
2
3
4
5
---
title: postname
date: 2020-01-20 21:00:37
tags:
---
1
hexo s

で現在のブログを仮想的に作成、確認できる。
http://localhost:4000
を見ると、



できてる。

source/_posts/postname.mdにちょっと追記。

1
2
3
4
5
6
7
8
9
10
11
12
13
---
title: postname
date: 2020-01-20 21:00:37
tags:
---

# h1
## h2
### h3
#### h4

なんか
**書く**
1
hexo s

でブログを確認。



できてる。

3. テーマ変更

テーマを使うとブログが簡単に良い感じになる。極めて便利。
Hexoの公式テーマが集まってる所があるので好きなのを選ぶ。見てると無限に時間がとける。



Icarusにする。かっこいいので。



ここに書いてある通りにする。

ターミナルに↓を打ってテーマをダウンロード。
git clone https://github.com/ppoffice/hexo-theme-icarus.git themes/icarus

themes/_config.ymlを開いて下のほうのthemeをicarusにする。

1
2
3
4
5
6
7
8
9
# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
theme: landscape # ← これをicarusに変える

# Deployment
## Docs: https://hexo.io/docs/deployment.html
deploy:
type: ''

続いて

1
hexo s

でブログを作成。

1
2
3
ERROR Package cheerio is not installed.
ERROR Please install the missing dependencies from the root directory of your
Hexo site.

されない。

言われた通りcheerioをインストールする。
ターミナルから

1
npm install cheerio

あらためてhexo sでブログを作成。

1
2
WARN  themes\icarus\_config.yml is not found. We are creating one for you...  
INFO themes\icarus\_config.yml is created. Please restart Hexo to apply changes.

されない。

言われた通りさらにもう一発hexo sでブログを確認。



最高のブログが出来てしまった。

4. ファイル出力

1
hexo generate

と打つと今のディレクトリにpublicフォルダが作られる。
public/index.htmlを開いても正しく表示されない。

画像やcssのリンクが正しくなさそうだったのでC:\の直下にpublicの中身をコピーして再度C:\index.htmlを開くときれいになる。C:\の直下はきたなくなった。後で全部消す。



この出力されたファイルをサーバに置いて外部公開するとブログって感じだ。

続き↓

タグ ,

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×