hugoをアップデートしたらhugoコマンドでエラーが出るようになった。
どうやら次の変更が原因っぽい。
The big new thing in this release is a fully refreshed template system – simpler and much better. We’re working on the updated documentation for this, but see this issue for some more information. We have gone to great lengths to make this as backwards compatible as possible, but make sure you test your site before going live with this new version. This version also comes with a full dependency refresh and some useful new template funcs:
hugoテーマの方で直してもらうしかないのだが、すぐに使いたかったので、hugoテーマをforkして自分で直した。 その後、hugo.tomlでforkしたものを指定したところ、うまく動かなった。 go moduleではforkしたものを使う場合、go.modの方でreplaceを使う必要があるみたい。
Go Module: forkしたpackageをimportし利用する方法
タグ付けはマストっぽい。
まず、githubでテーマをfork。そしたらforkしたものをローカルにclone。
$ git clone git@github.com:username/beautifulhugo.git
$ cd beautifulhugo
$ git config --local user.name (ユーザー名)
$ git config --local user.email (メールアドレス)
(エラーの原因を改変)
$ git tag v1.0.0
$ git add .
$ git commit -m "add tag"
$ git push orign v1.0.0
hugoサイトのディレクトリに移動。 いろいろめんどくさいので一旦初期化
$ cd hugo_site
$ rm -f go.mod go.sum
$ hugo mod init github.com/username/hugo_site
$ hugo mod get github.com/halogenica/beautifulhugo
すると、go.modが作成されて、その中身はこんな感じ。
module github.com/username/hugo_site
go 1.24.2
require github.com/halogenica/beautifulhugo v0.0.0 //indirect
ここに、replaceを追記
replace github.com/halogenica/beautifulhugo v0.0.0 => github.com/username/beautifulhugo v1.0.0
この状態で$ hugo mod get -u
をすると、forkしたテーマを使える。
なお、hugo.tomlのテーマは変更不要(オリジナルを指定する。)。
ちなみにエラーの原因はこれ。テーマの方にプルリしといた。