Hugoでこのブログに記事を投稿する手順をメモ。備忘録。

環境構築

リポジトリ

  • tac0x2a.github.io.src: Hugoでコンバートする前のソース
  • tac0x2a.github.io: 公開用のファイル群。Hugoで生成したファイルを置く
1
2
3
4
git clone git@github.com:tac0x2a/tac0x2a.github.io.src.git
cd tac0x2a.github.io.src
git submodule init
git submodule update

tac0x2a.github.io.src には 2つのsubmoduleが登録されている

  • public: 公開用のリポジトリ(tac0x2a.github.io)
  • themes/even: こちらのテーマを少し改造したもの。upstreamが更新されたら取り込みたい。

Hugoのインストール

WSL環境で。

1
2
wget https://github.com/gohugoio/hugo/releases/download/[version]/hugo_[version]_Linux-64bit.deb
sudo dpkg -i hugo_0.70.0_Linux-64bit.deb

Please see https://github.com/gohugoio/hugo/releases

記事を書く

1
2
3
4
hugo new post/yyyy-mm-dd-<title>.md

# 画像を記事に含める場合はこう。
hugo new post/yyyy-mm-dd-<title>/index.md

確認するにはこう

1
2
3
hugo serve -D
# open localhost:1313

themeを変更した場合はこんな感じ。

1
2
cd theme/even
sass --watch --sourcemap=none assets/sass/main.scss:resources/_gen/assets/scss/sass/main.scss_48b060fe05b0a273d182ef83c0605941.content

書き終わったら draft: truedraft: false に変える。

記事を公開する

1
2
chmod +x ./deploy.sh
./deploy.sh

公開の仕組み

  1. tac0x2a.github.io.srcpublicフォルダに生成されたファイル一式が出力される。
  2. publictac0x2a.github.ioをsubmoduleとして登録したものなので、配下でコミット&pushすることで記事を公開できる。