okkur / syna

Highly customizable open source theme for Hugo based static websites
https://syna.okkur.org/demo/
Apache License 2.0
251 stars 133 forks source link

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

Open solrayc opened 4 years ago

solrayc commented 4 years ago

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:

stp-ip commented 4 years ago

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

solrayc commented 4 years ago

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 commented 4 years ago

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

solrayc commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

Added this issue to Hugo forum https://discourse.gohugo.io/t/syna-theme-image-fallthrough-fails-on-windows-but-works-on-linux/21889

Similar to #630

stp-ip commented 4 years ago

Thanks for filing

stp-ip commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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.