CircleCI builds failing

Forgive me if this isn’t the place, but my CircleCI builds began failing today rather out of the blue.

This is my .circleci/config.yml file:

version: 2
      - image: cibuilds/hugo:latest
    working_directory: ~/hugo
      HUGO_BUILD_DIR: ~/hugo/public
      - run: apk update && apk add git
      - checkout
      - run: git submodule sync && git submodule update --init
      - run: curl -L | tar xvz
      - run: HUGO_ENV=production hugo -v -d $HUGO_BUILD_DIR
      - run: htmlproofer $HUGO_BUILD_DIR --allow-hash-href --check-html --empty-alt-ignore --disable-external
      - deploy:
          name: deploy
          command: |
            if [ "${CIRCLE_BRANCH}" = "master" ]; then
              ./s3deploy -source=$HUGO_BUILD_DIR -region=us-east-2 -distribution-id=XXXXXXXXXXXXXX -public-access
              echo "Not master branch, dry run only"

and here’s the error i’m facing:

#!/bin/bash -eo pipefail
htmlproofer $HUGO_BUILD_DIR --allow-hash-href --check-html --empty-alt-ignore --disable-external
Running ["HtmlCheck", "ScriptCheck", "ImageCheck", "LinkCheck"] on ["~/hugo/public"] on *.html... 

Ran on 37 files!

- ~/hugo/public/events/index.html
  *  463:45: ERROR: htmlParseEntityRef: expecting ';' (line 463)
  *  463:52: ERROR: htmlParseEntityRef: expecting ';' (line 463)
  *  463:59: ERROR: htmlParseEntityRef: expecting ';' (line 463)
  *  464:45: ERROR: htmlParseEntityRef: expecting ';' (line 464)
  *  464:52: ERROR: htmlParseEntityRef: expecting ';' (line 464)
  *  464:59: ERROR: htmlParseEntityRef: expecting ';' (line 464)
- ~/hugo/public/events/metro-west-community-leader-mixer/index.html
  *  540:45: ERROR: htmlParseEntityRef: expecting ';' (line 540)
  *  540:52: ERROR: htmlParseEntityRef: expecting ';' (line 540)
  *  540:59: ERROR: htmlParseEntityRef: expecting ';' (line 540)
  *  541:45: ERROR: htmlParseEntityRef: expecting ';' (line 541)
  *  541:52: ERROR: htmlParseEntityRef: expecting ';' (line 541)
  *  541:59: ERROR: htmlParseEntityRef: expecting ';' (line 541)
htmlproofer 3.10.2 | Error:  HTML-Proofer found 12 failures!
Exited with code 1

Could anyone point me in the right direction? I’m a little at a loss of how to even begin to debug this. Thanks in advance!

Have you looked at the html files listed in the output?

Thanks @zwbetz, yes…

The /events/index.html was an existing page, and here’s what i can pull from the file in the S3 bucket, lines 462 to 465:

srcset=" 1x, 2x, 3x"

The /events/metro-west-community-leader-mixer/index.html was created today by my client via and the generated html file is not showing up in my S3 bucket at all.

Going off the error message, it’s like html proofer doesn’t like something to do with the html character encoding

Hmm, i was having a really hard time getting Hugo to not escapte the & character (using safeHTML didn’t help), which is why i settled on the print function, which you can see in my image template here:

{{ $src := print $.imgixURL .src "?" }}
{{ $imgixDefaults := "auto=format" }}
srcset="{{ $src }}{{ with $.imgixParams }}{{ print . "&" }}{{ end }}{{ $imgixDefaults }} 1x,
        {{ $src }}{{ with $.imgixParams }}{{ print . "&" }}{{ end }}fit=max&q=40&dpr=2&{{ $imgixDefaults }} 2x,
        {{ $src }}{{ with $.imgixParams }}{{ print . "&" }}{{ end }}fit=max&q=20&dpr=3&{{ $imgixDefaults }} 3x"
src="{{ $src }}{{ with $.imgixParams }}{{ print . "&" }}{{ end }}{{ $imgixDefaults }}"

Perhaps there’s a better way to approach this?

I’ve seen folks do it like this:

{{ $some_var | htmlUnescape | safeHTML }}

Thanks for taking time with me on this.

No errors are thrown on my local instance—the site builds just fine. It’s only the circleCI build that’s failing. I made the change you suggested, but the problem continues.

{{ $src := print $.imgixURL .src "?" }}
{{ $imgixDefaults := "auto=format" }}
srcset="{{ $src }}{{ with $.imgixParams }}{{ print . "&" | htmlUnescape | safeHTML }}{{ end }}{{ $imgixDefaults | htmlUnescape | safeHTML }} 1x,
        {{ $src }}{{ with $.imgixParams }}{{ print . "&" | htmlUnescape | safeHTML }}{{ end }}fit=max&q=40&dpr=2&{{ $imgixDefaults | htmlUnescape | safeHTML }} 2x,
        {{ $src }}{{ with $.imgixParams }}{{ print . "&" | htmlUnescape | safeHTML }}{{ end }}fit=max&q=20&dpr=3&{{ $imgixDefaults | htmlUnescape | safeHTML }} 3x"
src="{{ $src }}{{ with $.imgixParams }}{{ print . "&" | htmlUnescape | safeHTML }}{{ end }}{{ $imgixDefaults | htmlUnescape | safeHTML }}"

I’m tempted to try and disable the html proofer. :roll_eyes:

Hmm so are you expecting this in your output?


Also, this post may be useful in your case, to change the template output type to plain text: HTML comment handling regression between 0.55.6 and 0.54.0

Nope, that & should be an (unescaped) &.

I checked on the image my client uploaded, and it contains spaces in the file name, Community Leaders Dinner.jpg.

I store this site’s media in a separate S3 bucket. So one of the files in question lives here:

And, so far as i can tell, the other file in question is here:

So i’m trying to narrow down on what’s causing the html proofer to fail the build:

  1. The ampersand escaping
  2. Files with special characters (e.g. spaces and capital letters)
  3. Some combination of both.

My guess is #1. Did you see my link for how to change the template output type to plain text?

Thanks again @zwbetz, i removed the spaces from the image file name and that cleared the build error, but the escaped & remains.

Before removing the spaces from the file name, here’s what i found for one of the pages throwing up the error:

<img srcset="#ZgotmplZw=730&amp;auto=format 1x,
             #ZgotmplZw=730&amp;fit=max&amp;q=40&amp;dpr=2&amp;auto=format 2x,
             #ZgotmplZw=730&amp;fit=max&amp;q=20&amp;dpr=3&amp;auto=format 3x"
  alt="community leaders at dinner">

(Notice the wonky srcset paths.)

When i removed the spaces from the file name, i got proper paths:

<img srcset=";auto=format 1x,
   ;fit=max&amp;q=40&amp;dpr=2&amp;auto=format 2x,
   ;fit=max&amp;q=20&amp;dpr=3&amp;auto=format 3x"
  alt="community leaders at dinner">

But, as you can see, the & continues to escape. I did check out that link and am investigating integrating into my project. Honestly i’m hesitant to make a change at the configuration level, since it seems as though my templates should work as is. This feels more like a bug. But i may have no choice—and i’m glad to have the recommendation from you. Truly appreciate your help.

The error states that it EXPECTS ; and doesn’t get it. This is the case in the &-attributes AFTER the first escaped &amp;. Try converting them to &amp; and it receives the ; it looks for.

You did not share much of your code, but this blackbox example looks to me as if you are using some HTML version that requires parameters in urls to be escaped. I remember having to do this back in the days of HTML 4.1 Transitional.