"{{ with }} branches end in different contexts" with Hugo 0.55


I have a couple of partials that generate schema.org ‘structured data’ for hugo-based site pages. With hugo 0.55.5 I am getting an error I did not get previously. An example error message:

Error: Error building site: failed to render pages: render of "page" failed: execute of template failed: template: post/single.html:16:4: executing "main" at <partial "seo-post-schema.html" .>: error calling partial: "/Volumes/CM/themes/with-branches-end-in-different-contexts/themes/common/layouts/partials/seo-post-schema.html:17:27": execute of template failed: html/template:partials/seo-post-schema.html:17:27: {{with}} branches end in different contexts: {stateJSDqStr delimNone urlPartNone jsCtxRegexp attrNone elementScript <nil>}, {stateJS delimNone urlPartNone jsCtxRegexp attrNone elementScript <nil>}

Evidently the problem is at this line in a (fairly) minimal repo set of sources that illustrate the problem. Note that the partials these occur in are part of a theme component that I use to share these among several sets of hugo site sources, if that makes any difference.

I am not good enough at hugo / go to decipher what the error means nor how to fix it. One theory I had was that the sample repo has no tags defined in the single content post it contains; but adding a tags definition does not seem to be the problem. Can someone help? Is this user error in the partial interaction between post/single.html and partials/seo-post-schema.html or some hugo regression?

An example of the kinds of content that a similar partial (used to) create prior to to hugo 0.55 can be seen here I have no web accessible version of the output of this particular partial but the errors generated by both now are identical.

Thanks in advance.



First of all when providing a sample repo it is expected that everything required by the project’s templates is included.

It is impossible to test your sample repo due to the following missing partials:

error calling partial: partial "social-follow.html" not found
error calling partial: partial "summary-with-image.html" not found
error calling partial: partial "site-footer.html" not found
error calling partial: partial "site-scripts.html" not found

Either include them or delete their references from the templates so that either I or someone else can have a further look into the issue you mention.

Also I suggest that you test the repo locally in case there are more missing partials.


My mistake in not including the gohugo-theme-ananke theme contents that have the dependencies. I’ve included those now in the sample repo. When I clone that locally the same error message gets generated so should for those trying to assist. Let me know if something more minimally demonstrative of the problem is desired.


There is a misplaced double quote that is causing the ERROR

Change line 17 of themes/common/layouts/partials/seo-post-schema.html


"keywords" : [ {{ with .Params.tags }}"{{ delimit . "\", \"" }}{{ end }}" ],


"keywords" : [ {{ with .Params.tags }}"{{ delimit . "\", \"" }}"{{ end }} ],

With this tiny change the sample repo renders without a problem on my end.


Wow, I would have spent ages trying to find that; thanks so much!

It makes perfect sense but now I am wondering why it ever worked. And now I see a new problem with my use of delimit and my minimal repo not actually displaying the problematic post but I’ll noodle on that for a while and update the git repo for anyone interested when I have a solution.