Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Minified build errors with: expected comma character or an array or object ending on line... #1441

Closed
pierreprinetti opened this issue Feb 28, 2024 · 4 comments · May be fixed by #1471
Labels
bug Something isn't working

Comments

@pierreprinetti
Copy link

pierreprinetti commented Feb 28, 2024

Describe the bug
I am getting this error when running hugo --minify:

Error: error building site: render: failed to render pages: failed to process "/posts/2024-02-27_reproducer/index.html": "/tmp/hugo-transform-error250503843:83:40": expected comma character or an array or object ending on line 83 and column 40
   12:     {
           ^

and indeed the tempfile has a scheme.org JSON array with two elements and no comma between them:

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "BreadcrumbList",
  "itemListElement": [
    {
      "@type": "ListItem",
      "position":  1 ,
      "name": "Posts",
      "item": "/posts/"
    }
    {
      "@type": "ListItem",
      "position":  1 ,
      "name": "This is a reproducer for a PaperMod bug",
      "item": "/posts/2024-02-27_reproducer/"
    }
  ]
}
</script>

I am not sure what triggers the error. Anyway, I could build a reproducer (see below).

  • Device/Os: N/A
  • Type: N/A
  • Browser and version: N/A
  • Hugo Version: 0.123.6
  • Theme Version: commit 55b2eb4

Steps to reproduce the behavior:

  1. Create a minimal post
  2. Generate a minified build
  3. enjoy

Expected behavior:
I expected the site to build, just like it does when no --minify is passed.

Repo/Source where this issue can be reproduced:

cd $(mktemp -d)
git clone --recurse-submodules git@github.com:pierreprinetti/papermod-bug-reproducer.git .
hugo --minify
@pierreprinetti pierreprinetti added the bug Something isn't working label Feb 28, 2024
@pierreprinetti
Copy link
Author

Something interesting happens when I set a base URL.

$ HUGO_BASEURL=https://example.com/ hugo --minify
Start building sites …
hugo v0.123.6+extended linux/amd64 BuildDate=unknown


                   | EN
-------------------+-----
  Pages            | 11
  Paginator pages  |  0
  Non-page files   |  0
  Static files     |  0
  Processed images |  0
  Aliases          |  2
  Cleaned          |  0

Total in 41 ms

First of all, it succeeds. And the breadcrumb JSON items now have the correct "position" numbers:

{
  "@context": "https://schema.org",
  "@type": "BreadcrumbList",
  "itemListElement": [
    {
      "@type": "ListItem",
      "position": 1,
      "name": "Posts",
      "item": "https://example.com/posts/"
    },
    {
      "@type": "ListItem",
      "position": 2,
      "name": "This is a reproducer for a PaperMod bug",
      "item": "https://example.com/posts/2024-02-27_reproducer/"
    }
  ]
}

(it was minified in the file; I have pretty-printed it here for readability)

@adityatelange
Copy link
Owner

Yes you are supposed to use a baseURL and not build with a / in baseURL, not recommended

@pierreprinetti
Copy link
Author

Yes you are supposed to use a baseURL and not build with a / in baseURL, not recommended

Do I understand correctly that not setting a baseURL is not a valid use-case with PaperMod?

@adityatelange
Copy link
Owner

Yes you are supposed to use a baseURL and not build with a / in baseURL, not recommended

Do I understand correctly that not setting a baseURL is not a valid use-case with PaperMod?

It's not only about use cases but what implementation works with the rest of the functions without breaking anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants