Anybody faced issue WARN 2023/01/16 11:36:47 .File.UniqueID on zero object. Wrap it in if or with: {{ with .File }}{{ .UniqueID }}{{ end }}

Hi, I am using zen theme and did customize only the single page. When I am running hugo server then everything is running very nicely and site is working locally like a charm.

But when I am using any command like hugoor hugo -v --gc --minify --cleanDestinationDir or hugo --minify --cleanDestinationDir getting warning and error and it is not building anything and halted after few seconds. Thew warning and errors are like the below:

WARN 2023/01/16 11:23:35 .File.UniqueID on zero object. Wrap it in if or with: {{ with .File }}{{ .UniqueID }}{{ end }}
ERROR 2023/01/16 11:23:35 failed to process "/co/i-look/index.html": "/var/folders/pd/mv2dbn5x4y9888zv6j6pzcj00000gn/T/hugo-transform-error2808677746:40:55": JSON parse error: unexpected comma character on line 40 and column 55
    9:     "description": ,
                          ^

Its wired and tried to check different posts here and also google it to find the solution. Also checked the .md files couple of times but I dint find any issue inside the ,md files. Applied different tips an techniques from different post suggestion one by one but still facing same issue. Any suggestion or if any body faced the same issue, can you tell me the approach to fix this.

thanks

The warning and the error are two different things. Let’s focus on the error.

Please post /co/i-look/index.html

Do you mean index.md or index.html file?

index.md file is like the below:

---

title: "1 iLook Technology Ltd."

date: 2021-09-02T01:43:45.831

update: 2023-01-12T14:35:45.805

draft: false

name: 1 iLook Technology Ltd.

tags:

- Computer And Internet

- Internet Service And E-Commerce

-

- 1

categories:

- Computer And Internet

subCategories:

- Internet Service And E-Commerce

address: 1/100, Block L, Gorgia

district:

country:

email:

phone: +123-2-34533

fax:

web:

xdescription:

- 1 iLook Technology Ltd is the best internet service provider (ISP) company

- Currently offering various digital services like Online Browsing,Broadband Connection, Webmail Facilities,E-Commerce etc.

---

I mean the file that it failed to process.

Here is the the html file for that page:
<!doctype html><html lang=en-gb><head><title>https://localhost/business/</title><link rel=canonical href=https://localhost.com/business/><meta name=robots content="noindex"><meta charset=utf-8><meta http-equiv=refresh content="0; url=https://localhost.com/business/"></head></html>

OK, that’s not helping. Either:

  1. Share your project repository, or
  2. Search your source for "description": and look for the malformed JSON

Also, which version of Hugo are you using?

Version: hugo v0.109.0+extended darwin/amd64 BuildDate=unknown

The Zen theme generates invalid JSON if the page doesn’t have content or a description in front matter:
https://github.com/frjo/hugo-theme-zen/blob/main/layouts/partials/meta_json_ld.html#L10

cc: @frjo

@jmooring Thanks for alerting me of this bug in the JSON output, I think I have fixed it now.

The warning is from the way the Zen theme build automatic menu. You can clear it by adding a “_index.md” for the home page or specifying a main menu.

1 Like

@rainGod Can you please test the fix and report back? If it works I will make a new release of the Zen theme. Thanks!

1 Like

Hif @frjo it is working now without any error. Tested on more then 10K files. Thanks a lot!!

Glad you find the Zen theme useful.

A new release with the fix is now out.

1 Like

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