resources.Concat failure

Any pointers why concat is failing here? GitHub - sonderant/hugotest

Where? :wink:

I must admit I did not check your repo.

Would be cool to reference the code where it fails. And the error message.

If it just does not produce what you want maybe some infos on the input, output, expectations…

And ofc what you did to get that.

This will speed up determining the issue for anyone who wants to dig into.

See: Requesting Help

You should! Everything you wrote down is in that repo. Run hugo sever. Check the css.html file in partials. (This is a basic new Hugo site btw).

You are attempting to concatenate different data types: a resource and a string.

Do this instead:

{{- /* styles */}}
{{- $localCSS := resources.Get "css/main.css" }}
{{- $normalizeCSS := "https://necolas.github.io/normalize.css/latest/normalize.css" }}
{{- with resources.GetRemote $normalizeCSS }}
  {{- with .Err }}
    {{- errorf "%s" . }}
  {{- else }}
    {{- $normalizeCSS = . }}
  {{- end }}
{{- else }}
  {{- errorf "Unable to get remote resource." }}
{{- end -}}

{{- $styles := slice $normalizeCSS $localCSS | resources.Concat "css/styles.css" }}
{{- if hugo.IsDevelopment }}
  {{- with $styles }}
    <link rel="stylesheet" href="{{- .RelPermalink }}">
  {{- end }}
{{- else }}
  {{- with $styles | minify | fingerprint }}
    <link rel="stylesheet" href="{{- .RelPermalink }}">
  {{- end }}
{{- end }}

You can use the warnf function to determine data type. For example:

{{ warnf "%[1]T %[2]d" $localCSS math.Counter }}
{{ warnf "%[1]T %[2]d" $normalizeCSS math.Counter }}

The resources.Concat function takes a slice of resources as its argument. Each element of the slice must be a resource, and all resources must have the same media type.

Works…another candidate for Improve error message in resources.Concat · Issue #7428 · gohugoio/hugo · GitHub

2 Likes

You added some code to this css file. What’s wrong telling that at the beginning. You know the line number…

Just slightly customized somewhere…

There’s nothing wrong with being more verbose to support your support staff.

https://github.com/gohugoio/hugo/pull/12807

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.