Hugo .Scratch not working in partials and advance usage of data files

Hello,

Thank you for the great work and awesome support.

Hugo is great for sites where content is written in .md files and we can use shortcodes here and there for more power. But if we want custom landing pages with section widgets, without repeating a lot of partials code, it needs some “hacks”. Bellow is a repo where i tried to create a landing page like i do with wordpress + ACF

I have some issues:

  1. trying to use .Scratch in a partial for advance classes without luck
  2. dot separated path for data file with index, without hardcoding

  1. I passed the current context as “el” and also the $.Site as “site” in the range, and when i try
{{ .site.Scratch.Set "classes" (slice "rp-body") }}  // in the cs-left.html

ERROR 2017/12/26 21:25:42 Error while rendering "page": template: /.../hugo-test/layouts/landing/page-builder.html:9:7: executing "main" at <partial $widget (dic...>: error calling partial: template: partials/page-builder/cs-left.html:1:8: executing "partials/page-builder/cs-left.html" at <.site.Scratch.Set>: can't evaluate field Scratch in type interface {}
  1. In the content/invoices.md i have a cdata param, and in layouts/landing/page-builder i have 2 index searches and a hardcoded folder “landing” index $language.landing how can i use something more general like cdata: landing.invoices in the index search.

Here is the test repo.

PS: I talked with forestry.io, and they will take it in account to have nested data files structure, and they use this technique for an enterprise client.

  1. Scratch works fine in partials if you pass on the correct context. I don’t have time to look at your specific project, maybe other will.
  2. https://github.com/gohugoio/hugo/issues/3289

Thank you for the fast response.

  1. the issue was the context, i learned how do it with with your help
  2. i will wait for this feature then

PS: the best support ever