Merging object arrays

In my site data, I have two arrays of objects located in two different files.


"array1": [
        "key1": "a",
        "key2": "b"
        "key1": "c",
        "key2": "d"


"array2": [
        "key1": "x",
        "key2": "y"

In Hugo v0.21, I was able to use the union function to merge these arrays and range over them with the same loop.

{{ range $loop := union $.Site.Data.file1.array1 $.Site.Data.file2.array2 }}
    <h1>{{ .key1 }}</h1>
    <p>{{ .key2 }}</p>
{{ end }}

Since updating to v0.26, I now get a fatal runtime error: hash of unhashable type map[string]interface {} error at this function.

Is it possible that union would support this again? Or is there another function that could accomplish this?

For what it’s worth, I’m not necessarily concerned with catching duplicate objects, just a simple merge of the two.

1 Like