LoginSignup
4
1

Hugo 0.53→0.55.6に上げたときの警告の対応方法

Last updated at Posted at 2019-06-30

はじめに

Hugo 0.53から0.55.6に上げると、以下のような警告が出ました。
テーマを0.55.6に対応するために行った方法を記載しておきます。

WARN 2019/06/25 22:11:33 Page's .Hugo is deprecated and will be removed in a future release. Use the global hugo function.
WARN 2019/06/25 22:11:33 Page's .URL is deprecated and will be removed in a future release. Use .Permalink or .RelPermalink. If what you want is the front matter URL value, use .Params.url.

対応方法

Page's .Hugo is deprecated and will be removed in a future release. Use the global hugo function.

これは、Page変数の .Hugo が今後使えなくなるよという内容です。以下で書かれている通り、 .Hugo.Generator と書かれていた箇所を hugo.Generator にしました。

Page’s .Hugo is deprecated and will be removed in a future release. Use the global hugo function.
For example: hugo.Generator.

Page's .URL is deprecated and will be removed in a future release. Use .Permalink or .RelPermalink. If what you want is the front matter URL value, use .Params.url.

ページ変数の .URL が今後使えなくなるようです。代替案は3つです。

  • .Permalink: 絶対URLの場合
  • .RelPermalink: 相対URLの場合
  • .Params.url: YAML Front Matterの url の場合

基本的には .RelPermalink でいいと思います。 git grep '\.URL' で検索して、コツコツ直していきました。

なぜこんな変更が入ったの?

変更はコツコツやればよかったのですが、なぜこのような変更をしたのかが気になって git blame で調べていたところ、以下のIssueにたどり着きました。

外部のデータからHugoに出力する要望で、魅力的な機能ですが、かなり大掛かりな変更が必要です。
なので内部を少しずつ変更している最中で、仕様変更が入ったようです。

この変更が入ったのが0.54で「だいたいはバグ修正」と書かれていますが、水面下でこのような大きな変更が入ってたんですね。

4
1
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
4
1