hugo/docs/content/en/functions/append.md
Bjørn Erik Pedersen df50c108ba docs: Add docs for append
See #5190
2018-09-14 10:12:08 +02:00

802 B

title description date categories menu keywords signature workson hugoversion relatedfuncs aliases
append `append` appends one or more values to a slice and returns the resulting slice. 2018-09-14
functions
docs
parent
functions
collections
COLLECTION | append VALUE [VALUE]...
COLLECTION | append COLLECTION
0.49
last
first
where
slice

An example appending single values:

{{ $s := slice "a" "b" "c" }}
{{ $s = $s | append "d" "e" }}
{{/* $s now contains a []string with elements "a", "b", "c", "d", and "e" */}}

The same example appending a slice to a slice:

{{ $s := slice "a" "b" "c" }}
{{ $s = $s | append (slice "d" "e") }}

The append function works for all types, including Pages.