Welcome to mirror list, hosted at ThFree Co, Russian Federation.

append.md « functions « en « content « docs - github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 732ffeaddb4d26aa9d7497e752fdff6ef8649c07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
---
title: append
description: "`append` appends one or more values to a slice and returns the resulting slice."
date: 2018-09-14
categories: [functions]
menu:
  docs:
    parent: "functions"
keywords: [collections]
signature: ["COLLECTION | append VALUE [VALUE]...", "COLLECTION | append COLLECTION"]
workson: []
hugoversion: "0.49"
relatedfuncs: [last,first,where,slice]
aliases: []
---

An example appending single values:

```go-html-template
{{ $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:


```go-html-template
{{ $s := slice "a" "b" "c" }}
{{ $s = $s | append (slice "d" "e") }}
```

The `append` function works for all types, including `Pages`.