---
url: https://docs.artemsemkin.com/velum/html/pages/archives.md
description: Change what an archive page lists and how it shows it.
---

# Archives

An archive lists projects or posts as cards: the Works pages and the journal. Each is one component, `PostsArchive`, whose cards are written into the page, so what it lists is the cards in the file and how it shows them is its options and classes.

| Page | How it shows the cards |
| --- | --- |
| `works.html` | Grid, by year, more cards on a click, the visitor switches to a list |
| `works-4-columns.html` | Four columns with filters by category |
| `works-list.html` | A list by year with filters by category |
| `works-dark.html` | Two columns on a dark page, more cards as the visitor scrolls |
| `works-pagination.html` | Grid with numbered pages |
| `works-lightbox.html` | Grid whose pictures open in the lightbox, with filters by year |
| `works-category-<name>.html` | One category's projects |
| `journal.html` | The posts as a list, more on a click |
| `journal-category-<name>.html` | One category's posts |

An archive split over several pages is several files: `works.html`, `works-page-2.html` and `works-page-3.html` each hold their own cards, and the archive's links lead from one to the next. Adding a card: [Add a project](./add-a-project) and [Add a post](./add-a-post).

## How to access

**Any archive page → `<div` with `data-arts-component-name="PostsArchive"`**

```html
<div
  class="posts-archive posts-archive_portfolio js-posts-archive posts-archive_filter-bar posts-archive_has-filters posts-archive_columns-4 posts-archive_gap-compact"
  data-posts-archive-view="grid"
  …
  data-arts-component-name="PostsArchive"
  data-arts-component-options='{"view":"grid","switchable":false,"paginationMode":"numbered","groupByFacet":"year","columnsChoices":[1,2,3,4],"filterFacet":"category"}'
```

## Changing the columns and the gaps

The classes on the archive set its columns on wide screens: `posts-archive_columns-2` or `posts-archive_columns-4`, and three without either. Its gaps are `posts-archive_gap-compact`, `posts-archive_gap-tight` or `posts-archive_gap-wide`, and the page's gutters without any. Works / 4 Columns in two wide columns:

```html
class="posts-archive posts-archive_portfolio js-posts-archive posts-archive_filter-bar posts-archive_has-filters posts-archive_columns-2 posts-archive_gap-wide"
```

## Showing a grid or a list

Set `"view"` in the options to `"grid"` or `"list"`, and `data-posts-archive-view` beside them to the same value. On an archive with `"switchable":true`, the visitor's own choice of grid or list is remembered and wins over yours when they come back.

```html
data-posts-archive-view="list"
…
data-arts-component-options='{"view":"list","switchable":true,"paginationMode":"load_more",…}'
```

## More cards on a click, or as the visitor scrolls

`"paginationMode":"load_more"` shows a button that loads the next file's cards; `"infinite"` loads them as the visitor reaches the end. Change it in every file of the archive. Infinite loading also needs this line right after the `<div class="posts-archive__more …">` that holds the more button, as `works-dark.html` has it:

```html
<div class="posts-archive__sentinel js-posts-archive__sentinel"></div>
```

Without that line the archive stops at its first file. For numbered pages, start from `works-pagination.html` and its two `-page-` files instead.

## Keeping the counts right

![The count beside the archive's heading is written into the page](https://docs.artemsemkin.com/velum/html/images/pages/archives-1.png)

The numbers an archive prints are text in the page, so a card you add or remove leaves them as they were. Change them in each file of the archive:

* the count beside the heading, `(16)`;
* `Showing All 16 Works` or `Showing All 7 Posts`, which the more button shows once every card is loaded;
* `Load 6 More`, the number of cards in the next file.

![The more button names the number of cards the next file holds](https://docs.artemsemkin.com/velum/html/images/pages/archives-2.png)

The filters and the year groups need no edit: they read each card's `data-grid-facets` and `data-grid-group`.

Next, the settings every page shares: [config.js](../settings/config-js).
