HUGO

Hugo + Netlify で独自ブログ開設を試みたが、ビルドでエラーが発生する

  1. 困ったこと
    Hugo + Netlifyで独自ブログ開設を試みたが、ビルドでエラーが発生する

  2. エラー内容
    11:54:55 PM: │ Netlify Build │
    11:54:55 PM: └─────────────────────────────┘
    11:54:55 PM: ​
    11:54:55 PM: ❯ Version
    11:54:55 PM: @netlify/build 3.3.0
    11:54:55 PM: ​
    11:54:55 PM: ❯ Flags
    11:54:55 PM: deployId: 5f42833354270439486cd0f5
    11:54:55 PM: mode: buildbot
    11:54:55 PM: ​
    11:54:55 PM: ❯ Current directory
    11:54:55 PM: /opt/build/repo
    11:54:55 PM: ​
    11:54:55 PM: ❯ Config file
    11:54:55 PM: /opt/build/repo/netlify.toml
    11:54:55 PM: ​
    11:54:55 PM: ❯ Context
    11:54:55 PM: production
    11:54:55 PM: ​
    11:54:55 PM: ┌────────────────────────────────────┐
    11:54:55 PM: │ 1. build.command from netlify.toml │
    11:54:55 PM: └────────────────────────────────────┘
    11:54:55 PM: ​
    11:54:55 PM: $ hugo --theme=zzo --buildDrafts --gc --minify
    11:55:00 PM: Building sites … ERROR 2020/08/23 14:55:00 JSON parse error: unexpected comma character on line 9 and column 20
    11:55:00 PM: 9: “description”: ,
    11:55:00 PM: ^
    11:55:00 PM: ERROR 2020/08/23 14:55:00 JSON parse error: unexpected comma character on line 9 and column 20
    11:55:00 PM: 9: “description”: ,
    11:55:00 PM: ^
    11:55:00 PM: Total in 5033 ms
    11:55:00 PM: Error: Error building site: failed to render pages: JSON parse error: unexpected comma character on line 9 and column 20
    11:55:00 PM: 9: “description”: ,
    11:55:00 PM: ^
    11:55:00 PM: ​
    11:55:00 PM: ┌─────────────────────────────┐
    11:55:00 PM: │ “build.command” failed │
    11:55:00 PM: └─────────────────────────────┘
    11:55:00 PM: ​
    11:55:00 PM: Error message
    11:55:00 PM: Command failed with exit code 255: hugo --theme=zzo --buildDrafts --gc --minify
    11:55:00 PM: ​
    11:55:00 PM: Error location
    11:55:00 PM: In build.command from netlify.toml:
    11:55:00 PM: hugo --theme=zzo --buildDrafts --gc --minify
    11:55:00 PM: ​
    11:55:00 PM: Resolved config
    11:55:00 PM: build:
    11:55:00 PM: command: hugo --theme=zzo --buildDrafts --gc --minify
    11:55:00 PM: commandOrigin: config
    11:55:00 PM: environment:
    11:55:00 PM: - HUGO_VERSION
    11:55:00 PM: - HUGO_ENV
    11:55:00 PM: - HUGO_ENABLEGITINFO
    11:55:00 PM: publish: /opt/build/repo/public
    11:55:00 PM: Caching artifacts
    11:55:00 PM: Started saving build plugins
    11:55:00 PM: Finished saving build plugins
    11:55:00 PM: Started saving pip cache
    11:55:00 PM: Finished saving pip cache
    11:55:00 PM: Started saving emacs cask dependencies
    11:55:00 PM: Finished saving emacs cask dependencies
    11:55:00 PM: Started saving maven dependencies
    11:55:00 PM: Finished saving maven dependencies
    11:55:00 PM: Started saving boot dependencies
    11:55:01 PM: Finished saving boot dependencies
    11:55:01 PM: Started saving go dependencies
    11:55:01 PM: Finished saving go dependencies
    11:55:03 PM: Error running command: Build script returned non-zero exit code: 1
    11:55:03 PM: Failing build: Failed to build site
    11:55:03 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 1
    11:55:03 PM: Finished processing build request in 18.205461886s

3.独自ブログのGitHubリポジトリ

  1. その他情報
    使用テーマ:Zzo

This is a problem with the Zzo theme. See:

Please raise the issue with the theme’s author.

1 Like

Options:

  1. Run hugo without the --minify option, OR

  2. Disable JSON minification by adding this to the bottom of your config.toml file:

     [minify]
     disableJSON = true
    
2 Likes

commit hash a7b1fb87599b76570654e9ddc3e74c52a8f0b2f9 https://github.com/KazuyaMatsunaga/capr1net-blog/tree/a7b1fb87599b76570654e9ddc3e74c52a8f0b2f9

の時点のリポジトリを clone して手元で build してみましたが (netlify.toml の通り hugo v0.71.0 でテスト) error は無かったですね。

git clone https://github.com/KazuyaMatsunaga/capr1net-blog.git
cd capr1net-blog
git submodule update --init --recursive
docker run --rm -i -t -v ${PWD}:/src peaceiris/hugo:v0.71.0 --theme=zzo --buildDrafts --gc --minify

ローカルでのビルドでエラーが発生するのであれば、何か手がかりをつかめそうですが、Netlify 上でのみエラーが発生するような状況でしょうか?

@jmooring が見つけてくれたように Build site JSON parse error · Issue #285 · zzossig/hugo-theme-zzo で zzo theme author も問題を再現できなかったようなので、かなり特殊な問題なのかもしれません。

とりあえずの回避策としては @jmooring と同じで disableJSON = true をオススメします。

1 Like

@jmooring が指摘してくれたように disableJSON = trueを追加し、リポジトリにpushしたら直りました.

またdisableJSON = trueを削除し、一回ローカルでビルドし、生成されたファイル(?)ごとリポジトリにpushしたら、それでもちゃんと動きました.

理由はよくわかりませんが、 @jmooring , @peaceiris さん、ありがとうございます.

1 Like