やったことのまとめ
Hugoを更新したHugoのThemeをBeautiful HugoからHugo Theme Stackに乗り換えた
つかうもの
- macOS Mojave 10.14
- Hugo v0.79.0
- 今回v0.56.3からv0.79.0に更新した
- Hugo Theme Stack
やったこと
Hugoの更新
使っているHugoのバージョンが結構古くなっていたので, 最新版にする.
自分の場合はbrewでインストールしているので, まずはbrew upgrade…
しようとしたら怒られた.
なんかGitHubとbrewの間でいろいろあって, shallow cloneをしないように変更があったらしい1.
# どうして...
$ brew update
Error:
homebrew-core is a shallow clone.
homebrew-cask is a shallow clone.
To `brew update`, first run:
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
This restriction has been made on GitHub's request because updating shallow
clones is an extremely expensive operation due to the tree layout and traffic of
Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
automatically to avoid repeatedly performing an expensive unshallow operation in
CI systems (which should instead be fixed to not use shallow clones). Sorry for
the inconvenience!
# 言われたとおりにする
$ git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
$ git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
# できた
$ brew update
Updated 2 taps (homebrew/core and homebrew/cask).気を取り直してHugoを更新する.
# 更新前の状態
$ hugo version
Hugo Static Site Generator v0.56.3/extended darwin/amd64 BuildDate: unknown
# hugoを更新
$ brew upgrade hugo
# 最新版になった
$ hugo version
Hugo Static Site Generator v0.79.0/extended darwin/amd64 BuildDate: unknownできた.
なんかおかしい
Hugoの更新後にブログの状態をローカルで確認するためにhugo serverを実行したらなんかやたらと警告が出た.
# ページを立ち上げてみる...
$ cd blog
$ hugo server -D
...
WARN 2020/12/17 23:55:53 Failed to get translated string for language "en" and ID "postedOnDate": template: :1:13: executing "" at <.Count>: can't evaluate field Count in type string
...なんかテンプレートに渡されるべきフィールドが変わっちゃってる?っぽくて直し方がよくわからなかった(無能)のと,
今まで使ってたBeautiful Hugoの開発が2019年の11月で止まっちゃってた2のもあって, これを機にThemeを変えることにした.(自分で作ろうとしないあたりがダメ)
Themeの変更
適当にThemeの一覧3を漁ってたら良さそうなのがあった.
Hugo Theme Stack4
シンプルなデザインでいい感じ.
このままtheme配下にsubmodule addしてもいいんだけど,
どうしても細かい変更がしたいことがあったりするのでforkして使わせていただく…
(ライセンスなどはいじらないこと!)
# themeを追加する
$ git submodule add https://github.com/uzimihsr/hugo-theme-stack.git themes/hugo-theme-stack
# サンプルサイトの内容をコピーする
$ cp -r ./themes/hugo-theme-stack/exampleSite/* ./あとはconfig.tomlの内容をconfig.yamlに書き直したり,
今までの記事の内容をcontent/post配下に移動したり画像ファイルの場所を変えたりしてお引越しは完了.
あまりにも泥臭い作業だったので詳細は省くけど,
今までとはpost配下の構造が違う(記事タイトルのディレクトリ配下にindex.mdと画像ファイルを配置する方式)ので元のブログ用ディレクトリの内容をいい感じにコピーするスクリプトを書いたりもした.
(ほんとにしょぼかったので割愛)
とりあえず元の記事は全部引っ越せたのでおしまい.
おわり
ブログのThemeを変えてみた.
前のデザインもシンプルで良かったけど, 新しいThemeもかなりいい感じ.
おまけ

