Unexpected syntax error on previous stable project

I’m running version 89.1 and fixing the tweet shortcode format. It recently started giving this error:

ERROR 2021/11/06 11:01:28 unexpected : in var statement on line 340 and column 24
    8:         var end: new Date(dt);
                      ^
ERROR 2021/11/06 11:01:28 expected ) instead of EOF in arguments on line 361 and column 77
    1: document.getElementById(
                               ^
Error: Error building site: failed to render pages: expected ) instead of EOF in arguments on line 298 and column 100
    1: document.getElementById(
                               ^
Total in 82503 ms

I’m still trying to track down where the offending code might be, but the first bit looks like core hugo.

Obviously somewhere in your JavaScript. I guess that the “:” in the first error should be a ";2 (or, given the following statement, rather a “=”, because otherwise new Date(dt) would not make much sense.

you’re right it was a piece of Javascript but it’s strange that Hugo would evaluate something that is already surrounded by <script>.

Do you have --minify enabled?

yes, I do.

With 0.88.1 and earlier, errors detected during minification were ignored. This was fixed with:
https://github.com/gohugoio/hugo/pull/8957

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.