Hugo --minify: failed to render pages

Hi there,

@zwbetz told me to open a thread here:
I am trying to use the --minify switch in hugo v51. But it gives me errors I cannot understand:

hugo server:

Building sites …
                   |  EN
+------------------+------+
  Pages            |  746
  Paginator pages  |  206
  Non-page files   | 6973
  Static files     |   99
  Processed images |    0
  Aliases          |  109
  Sitemaps         |    1
  Cleaned          |    0

Total in 4257 ms

hugo server --minify:

Building sites … ERROR 2018/11/22 17:12:03 parse error:22:15: expected comma character or an array or object ending
   22: <li>14:00 – 15:00 Advanced programming of Bots with LUIS and Cognitive Services &#8211; hands on!</li>
                     ^
ERROR 2018/11/22 17:12:03 parse error:7:291: expected comma character or an array or object ending
    7: Welcome to my almost live coverage of the Ignite 2016 in Atlanta, Georgia. Two years ago I attended the very last SharePoint Conference in Las Vegas and crafted 30 blog posts &#8211; and got good feedback afterwards. So well, this year I aim at 20 posts &#8211; lets see how it goes. Please excuse typos, I do fast releases!",
                                                                                                                                                                                                                                                                                                         ^
ERROR 2018/11/22 17:12:03 parse error:1:633: expected comma character or an array or object ending
    1: ection id=recent-posts><div class=mini-posts><header><h3>Recent Posts</h3></header><article class=mini-post><header><h3><a href=http://localhost:1313/post/2018-11-20-AzureSecureRDPLogin/>Simple Just-in-Time RDP/SSH Access to Azure VM</a></h3><time class=published datetime=2018-11-20>November 20, 2018</time></header><a href=http://localhost:1313/post/2018-11-20-AzureSecureRDPLogin/ class="image featured"><img src=http://localhost:1313/post/2018-11-20-AzureSecureRDPLogin/images/featured.jpg alt></a></article><article class=mini-post><header><h3><a href=http://localhost:1313/post/2018-11-15-AzurePolicy-InstalledApp/>Azure Policy: Audit Installed Applications</a></h3><time class=published datetime=2018-11-15>November 15, 2018</time></header><a href=http://localhost:1313/post/2018-11-15-AzurePolicy-InstalledApp/ class="image featured"><img src=http://localhost:1313/post/2018-11-15-AzurePolicy-InstalledApp/images/featured.png alt="Azure Policy to black list installed applications - Photo by Adam Griffith on Unsplash"></a></article><article class=mini-post><header><h3><a href=http://localhost:1313/post/2018-11-11-AppService-To-AzureStorage/>Penny Pinching: Migrating App Service to Azure Storage Website Hosting</a></h3><time class=published datetime=2018-11-11>November 11, 2018</time></header><a href=http://localhost:1313/post/2018-11-11-AppService-To-AzureStorage/ class="image featured"><img src=/images/2018/AzureStorage/katie-harp-pinterest-manager-1080597-unsplash.png alt="Penny Pinching: Migrating App Service to Azure Storage Website Hosting - Photo by Katie Harp - Pinterest Manager on Unsplash"></a></article><a hr
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ^
ERROR 2018/11/22 17:12:03 parse error:32:7: expected comma character or an array or object ending
   32:                     </li>
             ^
Total in 3453 ms
Error: Error building site: failed to render pages: parse error:18:32: expected comma character or an array or object ending
   18:                     "copyrightYear" : "2016",
                                      ^

The output of the --minify run is very confusing - the ^ point to valid html.

Any pointers how to fix it?

Thanks,
Max

Hi Max. Thanks for opening this topic. If you would, please share a link to your site code so that we can attempt to reproduce the issue.

For others, here’s the original GH issue: https://github.com/gohugoio/hugo/issues/5459

Hi there,

here is the repo:
https://mmelcher@dev.azure.com/mmelcher/Melcher.it%20Public/_git/melcher.it

Thanks,
Max

I get this error when trying to access it. You probably need to make it “public” or something like that.

1 Like

Strange - it’s public and the page renders fine for me. Please try again, maybe a temporary issue.

Just tried again. I get the same error.

Another option is to zip up your source code and post it here.

I’ve had a look at your repository. This probably won’t solve your problem, but is there a reason why the wp-uploads directory is inside your content directory, rather than the static directory? It looks to me to be full of images and other binary files which don’t need to be manipulated by Hugo.

Sure, I could move that - I migrated from Wordpress and the migration tool did that.

@funkydan2 Did not solve it - any further ideas?

I cloned it to github: https://github.com/MaxMelcher/Melcher.it

Remove the single quotes on lines 56-57 in the footer partial: https://github.com/MaxMelcher/Melcher.it/blob/master/themes/melcher/layouts/partials/footer.html#L56-L57

Then check your JSON and JavaScript syntax everywhere else.

remove the single quotes, no change.
Then I emptied my content folder and added the posts back and it somehow errors out when generating the page description:

The generated markup is not valid because of the <a href=" part.
Is that a hugo issue or should I report that in the minify component repo?

Thanks,
Max

This line is the one generating that html that is causing your error.

What happens is that the specific post on your screenshot is using the post’s .Summary, to generate the value for description, which contains html.

Specifically, it contains <a href="... .

In the html body, that would be valid markup, however, this line is being generated in the head, as value for json, and so the double quotes there makes the json invalid.

Perhaps if you pipe the .Summary through plainify it might help?

3 Likes

thanks a bunch, that worked!