2021-08-25 13:33:29 +02:00
+++
2021-09-11 15:46:14 +02:00
description = "The Attachments shortcode displays a list of files attached to a page"
2021-08-25 13:33:29 +02:00
title = "Attachments"
+++
2017-08-20 17:10:29 +02:00
The Attachments shortcode displays a list of files attached to a page.
{{% attachments /%}}
## Usage
The shortcurt lists files found in a **specific folder** .
Currently, it support two implementations for pages
2021-09-11 15:46:14 +02:00
1. If your page is a Markdown file, attachements must be placed in a **folder** named like your page and ending with ** .files**.
2017-08-20 17:10:29 +02:00
> * content
> * _index.md
> * page.files
> * attachment.pdf
> * page.md
2020-07-30 22:37:35 -04:00
2. If your page is a **folder** , attachements must be placed in a nested ** 'files'** folder.
2017-08-20 17:10:29 +02:00
> * content
> * _index.md
> * page
> * index.md
> * files
> * attachment.pdf
2017-08-20 22:29:35 +02:00
Be aware that if you use a multilingual website, you will need to have as many folders as languages.
2020-07-30 22:38:18 -04:00
That's all!
2017-08-20 17:10:29 +02:00
### Parameters
| Parameter | Default | Description |
|:--|:--|:--|
| title | "Attachments" | List's title |
2021-07-26 11:14:27 +02:00
| sort | "asc" | Sorting the output in `asc` ending or `desc` ending order |
| style | "" | Choose between `orange` , `grey` , `blue` and `green` for nice style |
2017-08-20 17:10:29 +02:00
| pattern | ".*" | A regular expressions, used to filter the attachments by file name. < br />< br /> The **pattern** parameter value must be [regular expressions ](https://en.wikipedia.org/wiki/Regular_expression ).
For example:
* To match a file suffix of 'jpg', use ** .*jpg** (not *.jpg).
* To match file names ending in 'jpg' or 'png', use ** .*(jpg|png)**
### Examples
#### List of attachments ending in pdf or mp4
2021-08-24 00:25:15 +02:00
````go
{{%/*attachments title="Related files" pattern=".*(pdf|mp4)"/*/%}}
````
2017-08-20 17:10:29 +02:00
renders as
{{%attachments title="Related files" pattern=".*(pdf|mp4)"/%}}
#### Colored styled box
2021-08-24 00:25:15 +02:00
````go
{{%/*attachments style="orange" /*/%}}
````
2017-08-20 17:10:29 +02:00
renders as
{{% attachments style="orange" /%}}
2021-08-24 00:25:15 +02:00
````go
{{%/*attachments style="grey" /*/%}}
````
2017-08-20 17:10:29 +02:00
2021-08-23 23:51:52 +02:00
renders as
2017-08-20 17:10:29 +02:00
{{% attachments style="grey" /%}}
2021-08-24 00:25:15 +02:00
````go
{{%/*attachments style="blue" /*/%}}
````
2017-08-20 17:10:29 +02:00
renders as
{{% attachments style="blue" /%}}
2021-08-23 23:51:52 +02:00
2021-08-24 00:25:15 +02:00
````go
{{%/*attachments style="green" /*/%}}
````
2017-08-20 17:10:29 +02:00
renders as
2020-07-30 22:38:18 -04:00
{{% attachments style="green" /%}}