# Page groups

A page group is one set of generated pages: a base page, a URL pattern, the
data sources that supply the rows, the mappings that write the rows into the
page, and the group's sitemap settings. You can create as many groups as you
need; each works independently.

## Creating a page group

Click **Create page group** on Rank's start page or on the **Page groups**
page, or on the page's first-run screen while there is no group yet.
Enter a name, an optional slug, the status, the base page and the URL pattern,
and click **Create page group**. A new group starts as a **Draft** with the
pattern `{slug}`; replace it with a static path such as `cities/{slug}` before
you publish (see [URL patterns](/docs/rank/page-groups/url-patterns.md)).

The group then appears in the sidebar under its name, with these pages:

| Page             | What it holds                                                            |
| ---------------- | ------------------------------------------------------------------------ |
| **General**      | name, slug, status, base page and URL pattern                            |
| **Data sources** | the sources and **Reload data**; its **Data** view lists the cached rows |
| **Mappings**     | how row values are written into the page                                 |
| **Sitemap**      | whether and how the group's URLs enter the sitemap                       |

All four pages edit one draft of the group: a change made on one page stays in
place while you move to another, and saving on any page stores the whole
group, changes made on the other pages included. While the draft differs
from the saved group, reloading or closing the page asks first.

A new group serves nothing until it has a data source and its data has been
loaded with **Reload data** (see
[Data sources](/docs/rank/page-groups/data-sources.md#loading-and-refreshing-the-data)).

## The General page

### Name

The name shown in the sidebar and the page group table.

### Slug

The group's identifier. Rank's rewrite rules route a matching URL to the group
by this slug, and the `sleekRank/data/item/{slug}` filter changes the rows of
this group only (see [Hooks](/docs/rank/hooks.md)). When it is left empty, the
slug is made from the name.

### Status

**Published** or **Draft**. Only a published group registers its URL pattern,
answers URLs and appears in the sitemap. A draft group does nothing on the
front end, but its pages can still be previewed in the workspace.

### Base page

The WordPress page whose rendered output every generated page starts from. Its
content, layout and theme output are kept, and the mappings change them.
While the group is published, the base page itself carries a `noindex`
robots tag and is left out of the WordPress core and The SEO Framework
sitemaps.

### URL pattern

The path of the generated pages, with exactly one `{slug}` placeholder that
is replaced by each row's `slug` value. `cities/{slug}` produces
`/cities/new-york/`, `/cities/london/` and so on. A pattern with no
placeholder or with two is refused when you save.

## Previewing generated pages

Every page of a group can show a preview pane beside it. The pane opens a
generated page in an embedded browser and reloads it after you save or reload
the data, so you see each change on a real page. It opens on the first row,
and you can navigate inside it; the slug links in the **Data** view open a
row's page in a new tab.

The preview is rendered for administrators through the site's front end with
`sleek_rank_preview` and `sleek_rank_slug` query parameters, so it works for
draft groups and before the rewrite rules are flushed. It needs the group's
data to be loaded, like any generated page. The WordPress toolbar stays hidden
in the preview, so the page shows as a visitor sees it.

Whether the pane is open is part of the page's address: `preview=1` on the
workspace's query, before `#/rank/page-groups/4`, opens page group 4 with the
preview showing, and the same `preview=1` works on the group's Data sources,
Data, Mappings and Sitemap pages.

## Managing page groups

The **Page groups** page lists every group with its status, 25 to a page, and
can be searched; the search and the page are part of the address
(`q` and `paged`). Its row actions open a group or delete it. Deleting asks
first and cannot be undone: it removes the group, its mappings, its cached rows
and its generated pages and their URLs; the base page stays.

Page groups can also be listed, created, changed and deleted with WP-CLI and
through the REST operations; see [CLI](/docs/rank/cli.md) and
[REST operations](/docs/rank/reference/rest.md).
