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

Issue with partials\helpers\image.html. [asset] image="image.png" breaks the site. #629

Open
solrayc opened this issue Nov 5, 2019 · 12 comments

Comments

@solrayc
Copy link

solrayc commented Nov 5, 2019

Is this a BUG REPORT or FEATURE REQUEST?:
bug

What happened:
I have content/_index/services.md list fragment with front matter parameter section = blog.
In content/blog/chocolate/ I have content fragment index.md and an image image.png.

Hugo throws an error when I set an image in fragment index.md, like so:

[asset]
  image = "image.png"

Here are the errors I get

Building sites … WARN 2019/11/05 19:05:16 .File.Dir on zero object. Wrap it in if or with: {{ with .File }}{{ .Dir }}{{ end }}
ERROR 2019/11/05 19:05:16 render of "home" failed: execute of template failed: template: _default\list.html:9:7: executing "_default\\list.html" at <partial "helpers/fragments-renderer.html" (dict "page_scratch" .Scratch)>: error calling partial: execute of template failed: template: partials/helpers/fragments-renderer.html:18:8: executing "partials/helpers/fragments-renderer.html" at <partial (print "fragments/" .Params.fragment ".html") $context>: error calling partial: "D:\Websites\mywebsite\themes\syna\layouts\partials\fragments\list.html:31:8": execute of template failed: template: partials/fragments/list.html:137:30: executing "partials/fragments/list.html" at <partial "helpers/image.html" (dict "root" $root "asset" .Params.asset)>: error calling partial: "D:\Websites\mywebsite\themes\syna\layouts\partials\helpers\image.html:31:8": execute of template failed: template: partials/helpers/image.html:31:8: executing "partials/helpers/image.html" at <fileExists (printf "content/%s" $location)>: error calling fileExists: CreateFile D:\Websites\mywebsite\content\%!s(<nil>)\image.png: The filename, directory name, or volume label syntax is incorrect.

ERROR 2019/11/05 19:05:16 render of "taxonomyTerm" failed: execute of template failed: template: _default\list.html:9:7: executing "_default\\list.html" at <partial "helpers/fragments-renderer.html" (dict "page_scratch" .Scratch)>: error calling partial: execute of 
template failed: template: partials/helpers/fragments-renderer.html:18:8: executing "partials/helpers/fragments-renderer.html" at <partial (print "fragments/" .Params.fragment ".html") $context>: error calling partial: "D:\Websites\mywebsite\themes\syna\layouts\partials\fragments\list.html:31:8": execute of template failed: template: partials/fragments/list.html:137:30: executing "partials/fragments/list.html" at <partial "helpers/image.html" (dict "root" $root "asset" .Params.asset)>: error calling partial: "D:\Websites\mywebsite\themes\syna\layouts\partials\helpers\image.html:31:8": execute of template failed: template: partials/helpers/image.html:31:8: executing "partials/helpers/image.html" at <fileExists (printf "content/%s" $location)>: error calling fileExists: CreateFile D:\Websites\mywebsite\content\%!s(<nil>)\image.png: The filename, directory name, or volume label syntax is incorrect.

ERROR 2019/11/05 19:05:16 render of "page" failed: execute of template failed: template: _default\single.html:9:7: executing "_default\\single.html" at <partial "helpers/fragments-renderer.html" (dict "page_scratch" .Scratch)>: error calling partial: execute of template failed: template: partials/helpers/fragments-renderer.html:18:8: executing "partials/helpers/fragments-renderer.html" at <partial (print "fragments/" .Params.fragment ".html") $context>: error calling partial: "D:\Websites\mywebsite\themes\syna\layouts\partials\fragments\list.html:31:8": execute of template failed: template: partials/fragments/list.html:137:30: executing "partials/fragments/list.html" at <partial "helpers/image.html" (dict "root" $root "asset" .Params.asset)>: error calling partial: 
"D:\Websites\mywebsite\themes\syna\layouts\partials\helpers\image.html:31:8": execute of template failed: template: partials/helpers/image.html:31:8: executing "partials/helpers/image.html" at <fileExists (printf "content/%s" $location)>: error calling fileExists: CreateFile D:\Websites\mywebsite\content\%!s(<nil>)\image.png: The filename, directory name, or volume label syntax is incorrect.

ERROR 2019/11/05 19:05:16 render of "taxonomyTerm" failed: execute of template failed: template: _default\list.html:9:7: executing "_default\\list.html" at <partial "helpers/fragments-renderer.html" (dict "page_scratch" .Scratch)>: error calling partial: execute of 
template failed: template: partials/helpers/fragments-renderer.html:18:8: executing "partials/helpers/fragments-renderer.html" at <partial (print "fragments/" .Params.fragment ".html") $context>: error calling partial: "D:\Websites\mywebsite\themes\syna\layouts\partials\fragments\list.html:31:8": execute of template failed: template: partials/fragments/list.html:137:30: executing "partials/fragments/list.html" at <partial "helpers/image.html" (dict "root" $root "asset" .Params.asset)>: error calling partial: "D:\Websites\mywebsite\themes\syna\layouts\partials\helpers\image.html:31:8": execute of template failed: template: partials/helpers/image.html:31:8: executing "partials/helpers/image.html" at <fileExists (printf "content/%s" $location)>: error calling fileExists: CreateFile D:\Websites\mywebsite\content\%!s(<nil>)\image.png: The filename, directory name, or volume label syntax is incorrect.
Total in 586 ms

Error: Error building site: failed to render pages: render of "page" failed: execute of template failed: template: _default\single.html:5:6: executing "_default\\single.html" at <partial "head.html" .>: error calling partial: "D:\Websites\mywebsite\themes\syna\layouts\partials\head.html:31:8": execute of template failed: template: partials/head.html:35:46: executing "partials/head.html" at <partial "helpers/image.html" (dict "root" $root "asset" .Params.asset "absolute" true)>: error calling partial: "D:\Websites\mywebsite\themes\syna\layouts\partials\helpers\image.html:31:8": execute of template failed: template: partials/helpers/image.html:31:8: executing "partials/helpers/image.html" at <fileExists (printf "content/%s" $location)>: error calling fileExists: CreateFile D:\Websites\mywebsite\content\%!s(<nil>)\image.png: The filename, directory name, or volume label syntax is incorrect.

What you expected to happen:
I expected to see a thumbnail image for the blog post in the list fragment on my homepage.
How to reproduce it (as minimally and precisely as possible):

You can reproduce this issue with my repo by uncommenting

[asset]
  image = "image.png"

in content/blog/chocolate/index.md
Anything else we need to know?:
I tried Hogo versions 0.58.3 and 0.59.1. Both throw the same error.
I fully rely on themes build in partials. I do not have any custom partials.
Environment:

  • Syna Theme version: v0.15.2
  • Hugo version:
Hugo Static Site Generator v0.59.1/extended windows/amd64 BuildDate: unknown
GOOS="windows"
GOARCH="amd64"
GOVERSION="go1.13.1"
@stp-ip stp-ip added the bug label Nov 7, 2019
@stp-ip stp-ip added this to the v0.16.0 milestone Nov 7, 2019
@stp-ip
Copy link
Member

stp-ip commented Nov 7, 2019

First idea would be:
section = "/blog" instead of section = blog

@solrayc
Copy link
Author

solrayc commented Nov 7, 2019

First idea would be:
section = "/blog" instead of section = blog

My current setup is section = "blog". I forgot to add "" in my message earlier, sorry.
List fragment works as it should, except for when I set the image in content/blog/article-1/index.md, like so:

[asset]
  image = "image.png"

Just like on Syna fragments example site.

Setting section = "/blog" in list fragment works the same way.

@stp-ip
Copy link
Member

stp-ip commented Nov 12, 2019

This might be related to #630 as both are issues with Windows based setups.
Does this work by using Linux?

@solrayc
Copy link
Author

solrayc commented Nov 13, 2019

This might be related to #630 as both are issues with Windows based setups.
Does this work by using Linux?

Looks like a windows issue. I encountered something similar with Hugo for Windows a while back with a different theme. Will test it out on Linux and report back.

@solrayc
Copy link
Author

solrayc commented Nov 16, 2019

Does this work by using Linux?

Just tested it with Linux and it works.
I believe it is an issue with Windows based setups.

Is this an issue with image fallthrough or image processing in Hugo for Windows environment?
I want to create an issue on this in Hugo community forum, but I don't really understand where the problem is. Can you assist me with correct description of this issue?

I tested on Debian WSL on Windows 10.

Hugo Static Site Generator v0.54.0/extended linux/amd64 BuildDate: 2019-06-04T19:16:36Z
GOOS="linux"
GOARCH="amd64"
GOVERSION="go1.11.6"

Syna version v0.14
Used older version of Syna, because I couldn't figure out how to update Hugo to latest version on Debian. I would've had to compile Hugo from source and that's just too many hoops to jump through.

@solrayc
Copy link
Author

solrayc commented Nov 20, 2019

@stp-ip
Copy link
Member

stp-ip commented Nov 20, 2019

Thanks for filing

@stp-ip
Copy link
Member

stp-ip commented Dec 1, 2019

@mpourismaiel Let's document this issue for windows and think about a possible solution. Most likely our code assuming path "/" separators for building paths or?

@mpourismaiel
Copy link
Member

Do we need to use "" for Windows? I thought Go or Hugo would handle that. I'll document the incompatibility for now and later maybe find a fix for it. Does the image appear if it's inside static directory? Is the problem restricted to fragment and page level fallthrough?

@solrayc
Copy link
Author

solrayc commented Dec 4, 2019

Does the image appear if it's inside static directory?

No, it does not. Errors are slightly different though.

Here are the errors I get when I set an image to be from static directory. On Windows:

Change detected, rebuilding site.
2019-12-04 19:27:04.365 +0800
Source changed "C:\\Users\\solrayc\\Desktop\\synastartergit\\syna-start\\content\\services\\berries\\index.md": WRITE
ERROR 2019/12/04 19:27:04 render of "home" failed: execute of template failed: template: _default\list.html:9:7: 
executing "_default\\list.html" at <partial "helpers/fragments-renderer.html" (dict "page_scratch" .Scratch)>: error calling partial: execute of template failed: template: partials/helpers/fragments-renderer.html:18:8: executing "partials/helpers/fragments-renderer.html" at <partial (print "fragments/" .Params.fragment ".html") $context>: error calling partial: "C:\Users\solrayc\Desktop\synastartergit\syna-start\themes\syna\layouts\partials\fragments\list.html:31:8": execute of template failed: template: partials/fragments/list.html:137:30: executing "partials/fragments/list.html" at <partial "helpers/image.html" (dict "root" $root "asset" .Params.asset)>: error calling partial: "C:\Users\solrayc\Desktop\synastartergit\syna-start\themes\syna\layouts\partials\helpers\image.html:31:8": execute of template failed: template: partials/helpers/image.html:31:8: executing "partials/helpers/image.html" at <fileExists (printf "content/%s" $location)>: error calling fileExists: CreateFile C:\Users\solrayc\Desktop\synastartergit\syna-start\content\%!s(<nil>)\header.jpg: The filename, directory name, or volume label syntax is incorrect.
ERROR 2019/12/04 19:27:04 render of "page" failed: execute of template failed: template: _default\single.html:9:7: executing "_default\\single.html" at <partial "helpers/fragments-renderer.html" (dict "page_scratch" .Scratch)>: error calling partial: execute of template failed: template: partials/helpers/fragments-renderer.html:18:8: executing "partials/helpers/fragments-renderer.html" at <partial (print "fragments/" .Params.fragment ".html") $context>: error calling partial: "C:\Users\solrayc\Desktop\synastartergit\syna-start\themes\syna\layouts\partials\fragments\list.html:31:8": execute of template failed: template: partials/fragments/list.html:137:30: executing "partials/fragments/list.html" at <partial "helpers/image.html" (dict "root" $root "asset" .Params.asset)>: error calling partial: "C:\Users\solrayc\Desktop\synastartergit\syna-start\themes\syna\layouts\partials\helpers\image.html:31:8": execute of template failed: template: partials/helpers/image.html:31:8: executing "partials/helpers/image.html" at <fileExists (printf "content/%s" $location)>: error calling fileExists: CreateFile C:\Users\solrayc\Desktop\synastartergit\syna-start\content\%!s(<nil>)\header.jpg: The filename, directory name, or volume label syntax is incorrect.
Total in 220 ms
ERROR 2019/12/04 19:27:04 Rebuild failed:

ERROR 2019/12/04 19:27:04 Failed to render pages: render of "page" failed: execute of template failed: template: 
_default\single.html:5:6: executing "_default\\single.html" at <partial "head.html" .>: error calling partial: "C:\Users\solrayc\Desktop\synastartergit\syna-start\themes\syna\layouts\partials\head.html:31:8": execute of template failed: template: partials/head.html:35:46: executing "partials/head.html" at <partial "helpers/image.html" (dict "root" $root "asset" .Params.asset "absolute" true)>: error calling partial: "C:\Users\solrayc\Desktop\synastartergit\syna-start\themes\syna\layouts\partials\helpers\image.html:31:8": execute of template failed: template: 
partials/helpers/image.html:31:8: executing "partials/helpers/image.html" at <fileExists (printf "content/%s" $location)>: error calling fileExists: CreateFile C:\Users\solrayc\Desktop\synastartergit\syna-start\content\%!s(<nil>)\header.jpg: The filename, directory name, or volume label syntax is incorrect.

Everything works well on Debian WSL, Windows 10.

@mpourismaiel
Copy link
Member

I recommend using WSL and building on Linux or using WSL for production as well. Supporting Windows is kinda hard and time consuming since none of us have a Windows development environment. We will investigate the issue given the chance. We are always happy to receive Pull Requests to improve our Windows support. I'm sorry for the inconvenience.

@stp-ip stp-ip modified the milestones: v0.16.0, v0.16.1 Dec 31, 2019
@stp-ip stp-ip removed this from the v0.16.1 milestone Jan 22, 2020
@stp-ip
Copy link
Member

stp-ip commented Jan 22, 2020

To add a last comment for now. We mainly support linux based systems. We'll leave this open to track and figure out what's the culprit over the long term. Assuming it might be due to our fragment logic, that adds "/" separators that are linux only.

@stp-ip stp-ip added the windows label Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants