{"record":{"id":"ff078de436b5f988","repo":"gohugoio/hugo","slug":"must-provide-one-or-more-resource-objects-to-conca","errorCode":null,"errorMessage":"must provide one or more Resource objects to concat","messagePattern":"must provide one or more Resource objects to concat","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/resources/resources.go","lineNumber":222,"sourceCode":"func (ns *Namespace) Concat(targetPathIn any, r any) (resource.Resource, error) {\n\ttargetPath, err := cast.ToStringE(targetPathIn)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar rr resource.Resources\n\n\tswitch v := r.(type) {\n\tcase resource.Resources:\n\t\trr = v\n\tcase resource.ResourcesConverter:\n\t\trr = v.ToResources()\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"expected slice of Resource objects, received %T instead\", r)\n\t}\n\n\tif len(rr) == 0 {\n\t\treturn nil, errors.New(\"must provide one or more Resource objects to concat\")\n\t}\n\n\treturn ns.bundlerClient.Concat(targetPath, rr)\n}\n\n// FromString creates a Resource from a string published to the relative target path.\nfunc (ns *Namespace) FromString(targetPathIn, contentIn any) (resource.Resource, error) {\n\ttargetPath, err := cast.ToStringE(targetPathIn)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tcontent, err := cast.ToStringE(contentIn)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn ns.createClient.FromString(targetPath, content)\n}","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/resources/resources.go#L204-L240","documentation":"Thrown by resources.Concat when the provided slice of resources is empty after conversion. Concat requires at least one Resource (typically more) to bundle into a single output. An empty slice, an empty .Resources collection, or a filtered collection that matched nothing produces this.","triggerScenarios":"Calling {{ resources.Concat \"bundle.css\" slice }}, {{ resources.Concat \"out.js\" ($assets | where ... ) }} where the filter matches nothing, or concatenating an empty .Resources.","commonSituations":"Conditional bundling where no files matched the glob/filter on some pages; iterating and collecting resources into a slice that ends up empty; typo in a Match pattern that returns nothing.","solutions":["Guard the call so Concat only runs when there is at least one resource: {{ if $assets }}{{ resources.Concat \"bundle.css\" $assets }}{{ end }}.","Verify your resources.Match/GetMatch pattern actually returns files.","Default to a fallback asset when the collection is empty."],"exampleFix":"// before\n{{ resources.Concat \"bundle.css\" ($assets | where \".RelPermalink\" \"ne\" \"\") }}\n// after\n{{ $bundle := $assets | where \".RelPermalink\" \"ne\" \"\" }}\n{{ with $bundle }}{{ resources.Concat \"bundle.css\" . }}{{ end }}","handlingStrategy":"validation","validationCode":"{{ with $assets }}{{ if gt (len .) 0 }}{{ resources.Concat \"bundle.css\" . }}{{ end }}{{ end }}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check the resource slice is non-empty before Concat.","Verify resources.Match/GetMatch patterns return files.","Provide a fallback asset for empty collections."],"tags":["template","resources","concat","validation","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}