poison icon indicating copy to clipboard operation
poison copied to clipboard

Can't render page on fresh installation "The filename, directory name, or volume label syntax is incorrect."

Open josephbadow opened this issue 1 year ago • 4 comments

I wanted to give this theme a spin and ran straight into an error. To make sure it's not my hugo setup I started from scratch in a different folder, but ran into the same issue.

  1. cd into C:\Users\Joseph\Gitlab
  2. hugo new site test-poison
  3. git clone https://github.com/lukeorth/poison.git themes/poison --depth=1
  4. Copy example config from https://poison.lukeorth.com/posts/introducing-poison/#example-config into hugo.toml
  5. hugo serve
Watching for changes in C:\Users\Joseph\Gitlab\test-poison\{archetypes,assets,content,data,i18n,layouts,static,themes}
Watching for config changes in C:\Users\Joseph\Gitlab\test-poison\hugo.toml, C:\Users\Joseph\Gitlab\test-poison\themes\poison\config.toml
Start building sites …
hugo v0.121.2-6d5b44305eaa9d0a157946492a6f319da38de154+extended windows/amd64 BuildDate=2024-01-05T12:21:15Z VendorInfo=gohugoio

ERROR render of "taxonomy" failed: "C:\Users\Joseph\Gitlab\test-poison\themes\poison\layouts\_default\baseof.html:1:3": execute of template failed: template: _default/list.html:1:3: executing "_default/list.html" at <partial "head/head.html" .>: error calling partial: "C:\Users\Joseph\Gitlab\test-poison\themes\poison\layouts\partials\head\head.html:16:7": execute of template failed: template: partials/head/head.html:16:7: executing "partials/head/head.html" at <partial "head/meta.html" .>: error calling partial: "C:\Users\Joseph\Gitlab\test-poison\themes\poison\layouts\partials\head\meta.html:31:6": execute of template failed: template: partials/head/meta.html:31:6: executing "partials/head/meta.html" at <fileExists $image_path_local>: error calling fileExists: CreateFile C:\Users\Joseph\Gitlab\test-poison\assets\%!!(MISSING)s(<nil>): The filename, directory name, or volume label syntax is incorrect.
ERROR render of "home" failed: "C:\Users\Joseph\Gitlab\test-poison\themes\poison\layouts\_default\baseof.html:1:3": execute of template failed: template: index.html:1:3: executing "index.html" at <partial "head/head.html" .>: error calling partial: "C:\Users\Joseph\Gitlab\test-poison\themes\poison\layouts\partials\head\head.html:16:7": execute of template failed: template: partials/head/head.html:16:7: executing "partials/head/head.html" at <partial "head/meta.html" .>: error calling partial: "C:\Users\Joseph\Gitlab\test-poison\themes\poison\layouts\partials\head\meta.html:31:6": execute of template failed: template: partials/head/meta.html:31:6: executing "partials/head/meta.html" at <fileExists $image_path_local>: error calling fileExists: CreateFile C:\Users\Joseph\Gitlab\test-poison\assets\%!!(MISSING)s(<nil>): The filename, directory name, or volume label syntax is incorrect.
Built in 73 ms
Error: error building site: render: failed to render pages: render of "taxonomy" failed: "C:\Users\Joseph\Gitlab\test-poison\themes\poison\layouts\_default\baseof.html:1:3": execute of template failed: template: _default/list.html:1:3: executing "_default/list.html" at <partial "head/head.html" .>: error calling partial: "C:\Users\Joseph\Gitlab\test-poison\themes\poison\layouts\partials\head\head.html:16:7": execute of template failed: template: partials/head/head.html:16:7: executing "partials/head/head.html" at <partial "head/meta.html" .>: error calling partial: "C:\Users\Joseph\Gitlab\test-poison\themes\poison\layouts\partials\head\meta.html:31:6": execute of template failed: template: partials/head/meta.html:31:6: executing "partials/head/meta.html" at <fileExists $image_path_local>: error calling fileExists: CreateFile C:\Users\Joseph\Gitlab\test-poison\assets\%!s(<nil>): The filename, directory name, or volume label syntax is incorrect.

I have a feeling that this could be a issue with windows path using \ instead of / on unix systems. Maybe it's also related to #148.

josephbadow avatar Jan 09 '24 20:01 josephbadow

Upon further inspection it seems that line 29 on partials/head/meta.html is causing trouble.

{{ $image_path_local :=  printf "assets/%s" $image_path -}}

It generates filepath like this

ERROR render of "taxonomy" failed [...] assets\%!!(MISSING)s(<nil>)
ERROR render of "home" failed [...] assets\%!!(MISSING)s(<nil>)
Error: error building site: render: failed to render pages: render of "taxonomy" failed [...] assets\%!s(<nil>)

But I have no idea how to write Hugo themes so maybe I'm completely on the wrong track 😅

(Just to be sure I also created a new post and set draft to false.)

josephbadow avatar Jan 09 '24 21:01 josephbadow

Just for reference, I installed Hugo into WSL (Ubuntu 22.04) and started it from the same folder:

/mnt/c/Users/Joseph/Gitlab/blog.bdw.li$ hugo serve
Watching for changes in /mnt/c/Users/Joseph/Gitlab/blog.bdw.li/{archetypes,assets,content,static,themes}
Watching for config changes in /mnt/c/Users/Joseph/Gitlab/blog.bdw.li/hugo.toml, /mnt/c/Users/Joseph/Gitlab/blog.bdw.li/themes/poison/config.toml
Start building sites …
hugo v0.121.2-6d5b44305eaa9d0a157946492a6f319da38de154+extended linux/amd64 BuildDate=2024-01-05T12:21:15Z VendorInfo=snap:0.121.2


                   | EN
-------------------+------
  Pages            | 136
  Paginator pages  |  12
  Non-page files   |   0
  Static files     | 367
  Processed images |   0
  Aliases          |   2
  Sitemaps         |   1
  Cleaned          |   0

Built in 7524 ms
Environment: "development"
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at //localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

As you can see, no issues at all.

josephbadow avatar Jan 16 '24 19:01 josephbadow

You can also try and og_image to the default params section worked for me change to mathcing image for you [params] og_image = "tn.jpg"

istern avatar Mar 05 '24 18:03 istern

I experienced the same on my Windows PC, and this theme is simply too good to skip, so I dived into the issue today and found the fix. I have opened a PR here: #181.

Simplest workaround until the PR is merged: Remove the comment and provide any (non-empty) value for og_image in hugo.toml/config.toml, as @istern also mentioned. Preferably a proper social icon, but the following will also fix the build:

og_image = "n/a"

Full explanation: This is definitely the same error as described in #148, and the problem is that the meta.html partial performs a fileExists call on the $image_path_local := printf "assets/%s" $image_path -}} variable, where $image_path is defined as {{ $image_path := .Params.image | default .Site.Params.og_image -}}.

Since the example config.toml comments out the og_image = "" param and there are no global front matter fields with key image, the image_path_local variable defaults to the following file path string: "\assets\%!s(<nil>)".

Since this path is illegal on Windows due to the percent sign, but not on Unix-based systems, only Windows users experience this error on build.

dbdness avatar May 01 '24 19:05 dbdness