insert - Liquid Filter Reference
On this page
Description
Inserts an item into a list at the supplied index
| Property | Value |
|---|---|
| Return Type | list |
| Category | lists |
Examples
```liquid
{{ my_list | insert: 99, 2 | join: “, “ }} ```
Output: 1, 2, 99, 3, 4, 5
```liquid
{{ my_list | insert: 99, -2 | join: “, “ }} ```
Output: 1, 2, 3, 4, 99, 5
```liquid
{{ my_list | insert: 99, 10 | join: “, “ }} ```
Output: 1, 2, 3, 4, 5, , , , , , 99
Was this article helpful?
Thanks for your feedback! It helps us improve our docs.