---
title: Preview Paths, Permalinks and Redirects
description: Set preview URLs for Sveltia CMS entries, store each entry’s path in its front matter, and record redirects when slugs change.
---

The `preview_path` option tells Sveltia CMS where an entry lives on your site, which enables site previews, deploy previews, permalinks stored in the entry itself, and automatic redirects when an entry’s slug changes.

## Preview Paths

The `preview_path` option allows you to define a custom URL path for previewing entries on your live site. This option accepts a string with template tags that will be replaced with entry-specific values when generating the preview URL. The CMS provides links to preview the entries based on this URL structure.

Without `preview_path`, the CMS can’t tell where an entry lives, so a published entry has no preview link. An unpublished entry in [Editorial Workflow](/docs/workflows/editorial) still links to the root of its [deploy preview](/docs/deployments/previews). The deploy preview’s address changes with each pull request, so the link is the easiest way to find it.

A `preview_path` that can’t be filled in for an entry, such as one with date tags on an entry whose date is empty, gives no link at all.

The path is appended to your site’s own address, or to the address of a build made for the entry when your repository is connected to a CI/CD provider. See [Deploy Previews](/docs/deployments/previews) for how those are found.

The [slug template tags](/docs/collections/entries/slugs#slug-template-tags) can be used in the `preview_path` option, with the following exceptions:

- `{{slug}}`: the entire slug of the entry, not just the slugified entry identifier.
- `{{year}}`, `{{month}}`, `{{day}}`, `{{hour}}`, `{{minute}}`, `{{second}}`: these tags are based on the entry’s [DateTime field](/docs/fields/datetime). The CMS looks for the first DateTime field in the collection to extract the date and time information. Use the `preview_path_date_field` option to specify a different top-level DateTime field.
  - If no DateTime field is found, the `preview_path` option will be ignored. A configuration warning is shown so the missing link doesn’t go unexplained.
  - A field that exists but is left empty on an entry has the same effect on that entry.
- `{{dirname}}`: the directory name of the entry file relative to the collection `folder`, without the locale folder of an [i18n structure](/docs/i18n/structures) with a folder per locale. This is useful when using the `path` option to create subfolders.
- `{{filename}}`: the filename of the entry without the extension. This is useful when you want to use the exact filename in the preview URL.
- `{{extension}}`: the file extension of the entry. This is useful when you want to include the file type in the preview URL.
- `{{locale}}`: the locale code of the entry when using [i18n support](/docs/i18n/slugs#preview-paths). This is useful when you want to include the locale in the preview URL.

Just like the `slug` and `path` options, any field name defined in the collection’s `fields` option can also be used as a template tag in `preview_path`. A field’s name may match one of the predefined tags listed above or in the [slug template tags](/docs/collections/entries/slugs#slug-template-tags), such as `slug`, `year` or `uuid`. If so, prefix it with `fields.`, like `{{fields.slug}}`, to avoid confusion with the tag itself.

You can use [string transformations](/docs/string-transformations) with these template tags.

The example below shows how to configure a blog posts collection with a custom preview URL structure.

```yaml YAML {5-6}
collections:
  - name: posts
    label: Blog Posts
    folder: /content/posts
    preview_path: '/blog/{{year}}/{{month}}/{{slug}}'
    preview_path_date_field: created_at
    fields:
      - { name: title, label: Title }
      - { name: created_at, label: Created At, widget: datetime }
      - { name: body, label: Body, widget: richtext }
```

```toml TOML {5-6}
[[collections]]
name = "posts"
label = "Blog Posts"
folder = "/content/posts"
preview_path = "/blog/{{year}}/{{month}}/{{slug}}"
preview_path_date_field = "created_at"
[[collections.fields]]
name = "title"
label = "Title"
[[collections.fields]]
name = "created_at"
label = "Created At"
widget = "datetime"
[[collections.fields]]
name = "body"
label = "Body"
widget = "richtext"
```

```json JSON {7-8}
{
  "collections": [
    {
      "name": "posts",
      "label": "Blog Posts",
      "folder": "/content/posts",
      "preview_path": "/blog/{{year}}/{{month}}/{{slug}}",
      "preview_path_date_field": "created_at",
      "fields": [
        { "name": "title", "label": "Title" },
        { "name": "created_at", "label": "Created At", "widget": "datetime" },
        { "name": "body", "label": "Body", "widget": "richtext" }
      ]
    }
  ]
}
```

```js JavaScript {7-8}
{
  collections: [
    {
      name: "posts",
      label: "Blog Posts",
      folder: "/content/posts",
      preview_path: "/blog/{{year}}/{{month}}/{{slug}}",
      preview_path_date_field: "created_at",
      fields: [
        { name: "title", label: "Title" },
        { name: "created_at", label: "Created At", widget: "datetime" },
        { name: "body", label: "Body", widget: "richtext" },
      ],
    },
  ],
}
```

With the above configuration, a blog post created on June 15, 2025, with the title “My First Post” will have a preview URL of `/blog/2025/06/my-first-post`.

Setting the `preview_path` option does two more things:

- It lets the CMS tell your framework where to build an entry. See [Permalinks](#permalinks) below.
- It lets the CMS keep links working when an entry is renamed. See [Redirects](#redirects) below.
- It’s what [Deploy Previews](/docs/deployments/previews) need in order to point at an entry. Without it, there’s nothing to append to the site or preview address, so no preview link is shown.

The `preview_path` and `preview_path_date_field` options can also be set on each file of a [file collection](/docs/collections/files#preview-path), where the collection-level options have no effect.

## Permalinks

Some frameworks read an entry’s output path from a front matter property. Sveltia CMS can fill that property from the [`preview_path` option](#preview-paths), so your site is built at the same path the CMS links to. You don’t have to reproduce the framework’s slug rules in `preview_path` or add the slug to each entry by hand.

This is turned off by default. Set the `permalink_field` option on an entry collection to enable it:

- `true`: use the `permalink` property.
- a string: use a property of that name, such as `url`.
- `false`: leave the property alone.

The example below stores the path in the `permalink` property, which [Eleventy](https://www.11ty.dev/docs/permalinks/) reads:

```yaml YAML {5-6}
collections:
  - name: portfolio
    label: Portfolio
    folder: /content/portfolio
    preview_path: 'portfolio/{{slug}}/'
    permalink_field: true
```

```toml TOML {5-6}
[[collections]]
name = "portfolio"
label = "Portfolio"
folder = "/content/portfolio"
preview_path = "portfolio/{{slug}}/"
permalink_field = true
```

```json JSON {7-8}
{
  "collections": [
    {
      "name": "portfolio",
      "label": "Portfolio",
      "folder": "/content/portfolio",
      "preview_path": "portfolio/{{slug}}/",
      "permalink_field": true
    }
  ]
}
```

```js JavaScript {7-8}
{
  collections: [
    {
      name: "portfolio",
      label: "Portfolio",
      folder: "/content/portfolio",
      preview_path: "portfolio/{{slug}}/",
      permalink_field: true,
    },
  ],
}
```

Saving an entry titled “Hello World” then results in the following front matter:

```yaml YAML
---
permalink: /portfolio/hello-world/
title: Hello World
---
```

```toml TOML
+++
permalink = "/portfolio/hello-world/"
title = "Hello World"
+++
```

```json JSON
{
  "permalink": "/portfolio/hello-world/",
  "title": "Hello World"
}
```

### Supported Frameworks

These frameworks set a page’s whole output path from a front matter property. Use the `permalink_field` value that matches yours:

| Framework | `permalink_field` value | Notes |
| --- | --- | --- |
| [Eleventy](https://www.11ty.dev/docs/permalinks/) | `true` | The path must end with a slash or a file extension. Otherwise, the build fails. |
| [Hexo](https://hexo.io/docs/front-matter) | `true` | The path must end with a slash or `.html`. |
| [Hugo](https://gohugo.io/content-management/urls/#url) | `url` | On a multilingual site, include the `{{locale}}` tag in `preview_path` where the language prefix belongs. |
| [Jekyll](https://jekyllrb.com/docs/permalinks/) | `true` |  |
| [Lume](https://lume.land/docs/creating-pages/urls/) | `url` | A path without a trailing slash or file extension creates a file without an extension. |
| [VuePress](https://vuepress.vuejs.org/reference/frontmatter.html) | `true` |  |
| [Zola](https://www.getzola.org/documentation/content/page/#front-matter) | `path` |  |

[Docusaurus](https://docusaurus.io/docs/create-doc) is different: its `slug` property is relative to the plugin’s route base path, such as `/docs`. Set `permalink_field` to `slug` only if `preview_path` leaves that base path out, which means the preview links won’t include it either.

Frameworks that define routes in code, such as Astro, Next.js and SvelteKit, have no such property, but you can read one in your own route code.

### How the Property Is Updated

- The path is filled in each time an entry is saved, for both new and existing entries, because it can depend on the slug and on any field.
- An existing entry gets the property the next time it’s saved. The CMS doesn’t update entries in bulk when you enable the option.
- [Bulk editing](/docs/collections/entries/operations#bulk-editing-entries), [relation updates](/docs/fields/relation#cascading-updates) and moving a folder of [nested entries](/docs/collections/entries/nested) also update the entries they rewrite. Renaming an asset and reordering entries don’t, so an entry whose path depends on an asset or its order is updated the next time it’s saved.
- The path always starts with a slash, whether or not `preview_path` does. The rest is kept as written, so a trailing slash has to come from `preview_path`.
- If the path can’t be filled in, such as when an entry’s date is empty, the property is removed so an outdated path can’t remain.

The CMS leaves the property alone in these cases:

- Its value isn’t a string, such as Eleventy’s `permalink: false`, which keeps a page from being built.
- The `preview_path` option isn’t defined.
- A field with the same name is defined in the `fields` option. The property is then left to the editor to manage.
- The entry is the collection’s [index file](/docs/collections/entries/listings#managing-hugo-s-special-index-file).

The option replaces any other string in the property, including a template you wrote by hand for your framework.

:::warning

The path is stored exactly as filled in. Eleventy renders a `permalink` value as a template, so a template tag that an editor types in a field referenced by `preview_path` would run at build time. Prefer `{{slug}}`, which can’t contain curly braces, over free-text fields such as `{{fields.title}}`.

:::

## Redirects

Changing an entry’s slug usually changes its URL, which breaks existing links to it, including internal links, external links and search engine results. To prevent this, Sveltia CMS can record the entry’s previous path in its data, so your framework can redirect visitors from the old URL to the new one.

This requires the [`preview_path` option](#preview-paths), because that option is what tells the CMS where an entry lives on your live site. Once it’s set, saving an entry with a modified slug adds the previous path to the entry’s `aliases` property:

- If the property doesn’t exist yet, it’s created as a list with a single item.
- If the property already exists as a list, the previous path is appended to it, so redirects accumulate as an entry is renamed over time.

Entry slugs can be changed in the [Slug panel](/docs/ui/content-editor#slug-panel) of the Content Editor’s sidebar.

With the `preview_path` configuration shown under [Preview Paths](#preview-paths), renaming a June 2025 blog post from `my-first-post` to `hello-world` results in the following front matter:

```yaml
---
aliases:
  - /blog/2025/06/my-first-post
title: Hello World
created_at: 2025-06-15T09:00:00.000Z
---
```

The `aliases` property is supported out of the box by [Hugo](https://gohugo.io/content-management/urls/#aliases) and [Zola](https://www.getzola.org/documentation/content/page/#front-matter), which generate the redirects for you. Other frameworks may expect a different property name or require a plugin.

### Customizing the Redirect Property

You can store the previous paths in a property other than `aliases` using the `aliases_field` option. For example, [Jekyll](https://jekyllrb.com/) sites using the [`jekyll-redirect-from`](https://github.com/jekyll/jekyll-redirect-from) plugin expect a `redirect_from` property:

```yaml YAML {6}
collections:
  - name: posts
    label: Blog Posts
    folder: /content/posts
    preview_path: '/blog/{{year}}/{{month}}/{{slug}}'
    aliases_field: redirect_from
```

```toml TOML {6}
[[collections]]
name = "posts"
label = "Blog Posts"
folder = "/content/posts"
preview_path = "/blog/{{year}}/{{month}}/{{slug}}"
aliases_field = "redirect_from"
```

```json JSON {8}
{
  "collections": [
    {
      "name": "posts",
      "label": "Blog Posts",
      "folder": "/content/posts",
      "preview_path": "/blog/{{year}}/{{month}}/{{slug}}",
      "aliases_field": "redirect_from"
    }
  ]
}
```

```js JavaScript {8}
{
  collections: [
    {
      name: "posts",
      label: "Blog Posts",
      folder: "/content/posts",
      preview_path: "/blog/{{year}}/{{month}}/{{slug}}",
      aliases_field: "redirect_from",
    },
  ],
}
```

### Disabling Redirects

If your framework doesn’t support redirects defined in entry data, set the `aliases_field` option to `false`. The CMS will then leave the property untouched when an entry is renamed, and no redirects will be generated.

```yaml YAML {6}
collections:
  - name: posts
    label: Blog Posts
    folder: /content/posts
    preview_path: '/blog/{{year}}/{{month}}/{{slug}}'
    aliases_field: false
```

```toml TOML {6}
[[collections]]
name = "posts"
label = "Blog Posts"
folder = "/content/posts"
preview_path = "/blog/{{year}}/{{month}}/{{slug}}"
aliases_field = false
```

```json JSON {8}
{
  "collections": [
    {
      "name": "posts",
      "label": "Blog Posts",
      "folder": "/content/posts",
      "preview_path": "/blog/{{year}}/{{month}}/{{slug}}",
      "aliases_field": false
    }
  ]
}
```

```js JavaScript {8}
{
  collections: [
    {
      name: "posts",
      label: "Blog Posts",
      folder: "/content/posts",
      preview_path: "/blog/{{year}}/{{month}}/{{slug}}",
      aliases_field: false,
    },
  ],
}
```

The same applies if you define a field with the same name as the redirect property in the `fields` option. The CMS assumes that the redirects are to be managed in the Content Editor, so it won’t write to the property on its own. This is the way to go to curate the list by hand while still being able to see and edit it in the CMS.
