# Attachments

The Attachments shortcode displays a list of files attached to a page.

Attachments

- adivorciarsetoca00cape.pdf (361 KB)
- BachGavotteShort.mp3 (357 KB)
- Carroll_AliceAuPaysDesMerveilles.pdf (175 KB)
- hugo.png (17 KB)
- hugo.txt (20 B)
- movieselectricsheep-flock-244-32500-2.mp4 (340 KB)

## Usage

The shortcurt lists files found in a specific folder. Currently, it support two implementations for pages

1. If your page is a Markdown file, attachements must be placed in a folder named like your page and ending with .files.

   > - content
   >   - _index.md
   >   - page.files
   >     - attachment.pdf
   >   - page.md

2. If your page is a folder, attachements must be placed in a nested ‘files’ folder.

   > - content
   >   - _index.md
   >   - page
   >     - index.md
   >     - files
   >       - attachment.pdf

Be aware that if you use a multilingual website, you will need to have as many folders as languages.

That’s all!

### Parameters

Parameter | Default | Description
--- | --- | ---
title | “Attachments” | List’s title
sort | “asc” | Sorting the output in `asc`ending or `desc`ending order
style | "" | Choose between `orange`, `grey`, `blue` and `green` for nice style
pattern | “.*” | A regular expressions, used to filter the attachments by file name. The pattern parameter value must be regular expressions.

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

    {{%attachments title="Related files" pattern=".*(pdf|mp4)"/%}}

renders as

Related files

- adivorciarsetoca00cape.pdf (361 KB)
- Carroll_AliceAuPaysDesMerveilles.pdf (175 KB)
- movieselectricsheep-flock-244-32500-2.mp4 (340 KB)

#### Colored styled box

    {{%attachments style="orange" /%}}

renders as

Attachments

- adivorciarsetoca00cape.pdf (361 KB)
- BachGavotteShort.mp3 (357 KB)
- Carroll_AliceAuPaysDesMerveilles.pdf (175 KB)
- hugo.png (17 KB)
- hugo.txt (20 B)
- movieselectricsheep-flock-244-32500-2.mp4 (340 KB)

    {{%attachments style="grey" /%}}

renders as

Attachments

- adivorciarsetoca00cape.pdf (361 KB)
- BachGavotteShort.mp3 (357 KB)
- Carroll_AliceAuPaysDesMerveilles.pdf (175 KB)
- hugo.png (17 KB)
- hugo.txt (20 B)
- movieselectricsheep-flock-244-32500-2.mp4 (340 KB)

    {{%attachments style="blue" /%}}

renders as

Attachments

- adivorciarsetoca00cape.pdf (361 KB)
- BachGavotteShort.mp3 (357 KB)
- Carroll_AliceAuPaysDesMerveilles.pdf (175 KB)
- hugo.png (17 KB)
- hugo.txt (20 B)
- movieselectricsheep-flock-244-32500-2.mp4 (340 KB)

    {{%attachments style="green" /%}}

renders as

Attachments

- adivorciarsetoca00cape.pdf (361 KB)
- BachGavotteShort.mp3 (357 KB)
- Carroll_AliceAuPaysDesMerveilles.pdf (175 KB)
- hugo.png (17 KB)
- hugo.txt (20 B)
- movieselectricsheep-flock-244-32500-2.mp4 (340 KB)