Hello,
I’m developing a site with Hugo driven by data (.yaml file inside data dir). It’s quite complex but basically I have a lot of yaml file for each “piece” of html that I can put in the site.
For the image I put the image inside the assets directory and in the yaml file something similar to this:
Image:
IsPresent: true
ImageUrl: "img/mockup/homepage/contacts/contacts00/770x502/img01.png"
ImageDescription: "Suspendisse tellus"
where inside the ImageUrl there is the path to the file. In the layout I put something like this:
{{ $img1 := resources.Get (string .data.Image.ImageUrl) }}
where .data is a variable passed to the partials when calling it. So far so good for a lot of “modules” of my website but for one of them it’s 2 days that I’m not figure out why it gives me error.
Well if I put this:
{{ $imagepath := .data.Image.ImageUrl}}
<H2>{{ $imagepath }}</H2>
{{ $img1 := resources.Get "img/mockup/homepage/contacts/contacts00/770x502/img01.png" }}
<h2>{{$img1.Permalink}}</h2>
it works like a charm and it render this:
If I change in this way:
{{ $imagepath := .data.Image.ImageUrl}}
<H2>{{ $imagepath }}</H2>
{{ $img1 := resources.Get (string $imagepath) }}
<h2>{{$img1.Permalink}}</h2>
that is pretty the same thing (as you can see the text variable contains the same text) it gives me a horrible error:
```
render of "page" failed: execute of template failed: template: misc/landing_pages_00.html:352:15: executing "main" at <partial "home_land/contacts/04_contacts" (dict "context" $.Site "data" $data)>: error calling partial: "C:\SourceCode\websites\hugo\template\Hugo_Themes\layouts\partials\home_land\contacts\04_contacts.html:3:21": execute of template failed: template: partials/home_land/contacts/04_contacts.html:3:21: executing "partials/home_land/contacts/04_contacts.html" at <resources.Get>: error calling Get: dirs not supported resource types: &{0xc00be7b1c0 map[baseDir:C:\SourceCode\websites\hugo\template\Hugo_Themes\ filename:assets fs:0xc0006d0c60 isOrdered:false lang: mountRoot: mountWeight:1 opener:0xc47640 watch:true]}
Rebuild failed:
Failed to render pages: render of "page" failed: execute of template failed: template: misc/landing_pages_00.html:352:15: executing "main" at <partial "home_land/contacts/04_contacts" (dict "context" $.Site "data" $data)>: error calling partial: "C:\SourceCode\websites\hugo\template\Hugo_Themes\layouts\partials\home_land\contacts\04_contacts.html:3:21": execute of template failed: template: partials/home_land/contacts/04_contacts.html:3:21: executing "partials/home_land/contacts/04_contacts.html" at <resources.Get>: error calling Get: dirs not supported resource types: &{0xc00fd17070 map[baseDir:C:\SourceCode\websites\hugo\template\Hugo_Themes\ filename:assets fs:0xc0006d0c60 isOrdered:false lang: mountRoot: mountWeight:1 opener:0xc47640 watch:true]}
```
```
github.com/gohugoio/hugo/hugolib.(*Site).renderPages
/root/project/hugo/hugolib/site_render.go:105
github.com/gohugoio/hugo/hugolib.(*Site).render
/root/project/hugo/hugolib/site.go:1091
github.com/gohugoio/hugo/hugolib.(*HugoSites).render
/root/project/hugo/hugolib/hugo_sites_build.go:338
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build.func4
/root/project/hugo/hugolib/hugo_sites_build.go:136
runtime/trace.WithRegion
/usr/local/go/src/runtime/trace/annotation.go:137
github.com/gohugoio/hugo/hugolib.(*HugoSites).Build
/root/project/hugo/hugolib/hugo_sites_build.go:138
github.com/gohugoio/hugo/commands.(*commandeer).rebuildSites
/root/project/hugo/commands/hugo.go:744
github.com/gohugoio/hugo/commands.(*commandeer).handleEvents
/root/project/hugo/commands/hugo.go:1104
github.com/gohugoio/hugo/commands.(*commandeer).newWatcher.func1
/root/project/hugo/commands/hugo.go:851
runtime.goexit
/usr/local/go/src/runtime/asm_amd64.s:1357
```
It make me crazy because with the same technique in other part works without any problem.
Is somebody that can help me?