---
title: Localized Slugs and Preview Paths
description: Localize entry slugs, make them editable per locale, use UUIDs for non-Latin content, and include the locale in preview paths in Sveltia CMS.
---

When i18n is enabled for an entry collection, [managing entry slugs](/docs/collections/entries/slugs#entry-slugs) (filenames) across different locales can be challenging. Sveltia CMS offers two solutions: localized entry slugs and UUID-based slugs.

## Localizing Entry Slugs

In Sveltia CMS, it’s possible to localize entry slugs (filenames) if the i18n structure is `multiple_files`, `multiple_folders` or `multiple_root_folders`, or the `folder` option contains the `{{locale}}` placeholder. All you need is the `localize` filter for `slug` template tags:

```yaml YAML {13}
i18n:
  structure: multiple_folders
  locales: [en, fr]

slug:
  encoding: ascii
  clean_accents: true

collections:
  - name: posts
    label: Blog posts
    folder: /content/posts
    slug: '{{title | localize}}'
    format: yaml
    i18n: true
    fields:
      - name: title
        label: Title
        widget: string
        i18n: true
```

```toml TOML {11}
[i18n]
structure = "multiple_folders"
locales = ["en", "fr"]
[slug]
encoding = "ascii"
clean_accents = true
[[collections]]
name = "posts"
label = "Blog posts"
folder = "/content/posts"
slug = "{{title | localize}}"
format = "yaml"
i18n = true
[[collections.fields]]
name = "title"
label = "Title"
widget = "string"
i18n = true
```

```json JSON {15}
{
  "i18n": {
    "structure": "multiple_folders",
    "locales": ["en", "fr"]
  },
  "slug": {
    "encoding": "ascii",
    "clean_accents": true
  },
  "collections": [
    {
      "name": "posts",
      "label": "Blog posts",
      "folder": "/content/posts",
      "slug": "{{title | localize}}",
      "format": "yaml",
      "i18n": true,
      "fields": [
        {
          "name": "title",
          "label": "Title",
          "widget": "string",
          "i18n": true
        }
      ]
    }
  ]
}
```

```js JavaScript {15}
{
  i18n: {
    structure: "multiple_folders",
    locales: ["en", "fr"],
  },
  slug: {
    encoding: "ascii",
    clean_accents: true,
  },
  collections: [
    {
      name: "posts",
      label: "Blog posts",
      folder: "/content/posts",
      slug: "{{title | localize}}",
      format: "yaml",
      i18n: true,
      fields: [
        {
          name: "title",
          label: "Title",
          widget: "string",
          i18n: true,
        },
      ],
    },
  ],
}
```

With this configuration, an entry is saved with localized filenames. The default locale’s slug is stored in each file as an extra `translationKey` property, which [Hugo’s multilingual support](https://gohugo.io/content-management/multilingual/#bypassing-default-linking) uses. Sveltia CMS and Hugo read this property to link localized files.

For example, if a blog post is created with the title “My trip to New York” in English and “Mon voyage à New York” in French, the following files will be created:

- `content/posts/en/my-trip-to-new-york.yaml`
  ```yaml
  translationKey: my-trip-to-new-york
  title: My trip to New York
  ```
- `content/posts/fr/mon-voyage-a-new-york.yaml`
  ```yaml
  translationKey: my-trip-to-new-york
  title: Mon voyage à New York
  ```

With the [`clean_accents` option](/docs/collections/entries/slugs#global-slug-options) enabled, as in the example above, each localized slug is transliterated with the rules for its own locale, if the [`transliterate` library](https://github.com/sindresorhus/transliterate#supported-locales) has rules for it. For example, `ö` becomes `oe` in a German slug but `o` in a Swedish one. A slug shared by every locale and a slug in a collection without i18n support use the locale set with the [`transliterate_locale` option](/docs/collections/entries/slugs#global-slug-options) instead, or the library’s generic rules if the option isn’t set.

You can customize the property name and value for a different framework or i18n library by adding the `canonical_slug` option to your top-level or collection-level `i18n` configuration. The example below is for [@astrolicious/i18n](https://github.com/astrolicious/i18n), which requires a locale prefix in the value ([discussion](https://github.com/sveltia/sveltia-cms/issues/137)):

```yaml YAML
i18n:
  canonical_slug:
    key: defaultLocaleVersion # default: translationKey
    value: 'en/{{slug}}' # default: {{slug}}
```

```toml TOML
[i18n]
canonical_slug = { key = "defaultLocaleVersion", value = "en/{{slug}}" }
```

```json JSON
{
  "i18n": {
    "canonical_slug": {
      "key": "defaultLocaleVersion",
      "value": "en/{{slug}}"
    }
  }
}
```

```js JavaScript
{
  i18n: {
    canonical_slug: {
      key: "defaultLocaleVersion",
      value: "en/{{slug}}",
    },
  },
}
```

For [Jekyll](https://migueldavid.eu/how-to-make-jekyll-multilingual-c13e74c18f1c), you may want to use the `ref` property:

```yaml YAML
i18n:
  canonical_slug:
    key: ref
```

```toml TOML
[i18n]
canonical_slug = { key = "ref" }
```

```json JSON
{
  "i18n": {
    "canonical_slug": {
      "key": "ref"
    }
  }
}
```

```js JavaScript
{
  i18n: {
    canonical_slug: {
      key: "ref",
    },
  },
}
```

In a collection with [nested entries](/docs/i18n/structures#nested-entries), the slug names the entry’s folder, so localizing the slugs also gives every locale its own [folder names](/docs/i18n/structures#localized-folder-names).

## Making Slugs Editable

Localized slugs can be edited for each locale in the [Slug panel](/docs/ui/content-editor#slug-panel) of the Content Editor, which has a section for each locale. When the slugs aren’t localized, a single slug is shared by every locale.

Instead of adding the `localize` filter to the template tags, you can localize the slugs with the `i18n` option of the [slug options object](/docs/collections/entries/slugs#making-slugs-editable). It accepts the following values:

- `true`: Each locale has a slug of its own. Every field tag in the template is filled with the locale’s own value, so `slug: { template: '{{title}}', i18n: true }` is equivalent to `slug: '{{title | localize}}'`.
- `duplicate` (default) or `false`: The default locale’s slug is shared by every locale.

Like the `localize` filter, the `i18n` option only has an effect with the `multiple_files`, `multiple_folders` or `multiple_root_folders` structure, or a `folder` with the [`{{locale}}` placeholder](/docs/i18n/structures#custom-locale-folder-placement), where each locale has a file of its own.

To have users [type a slug](/docs/collections/entries/slugs#having-users-type-the-slug) for each locale, combine it with the `editable` option, without a `template`:

```yaml YAML {5-7}
collections:
  - name: posts
    label: Blog Posts
    folder: /content/posts
    slug:
      editable: true
      i18n: true
```

```toml TOML {6-8}
[[collections]]
name = "posts"
label = "Blog Posts"
folder = "/content/posts"

[collections.slug]
editable = true
i18n = true
```

```json JSON {7-10}
{
  "collections": [
    {
      "name": "posts",
      "label": "Blog Posts",
      "folder": "/content/posts",
      "slug": {
        "editable": true,
        "i18n": true
      }
    }
  ]
}
```

```js JavaScript {7-10}
{
  collections: [
    {
      name: "posts",
      label: "Blog Posts",
      folder: "/content/posts",
      slug: {
        editable: true,
        i18n: true,
      },
    },
  ],
}
```

:::warning[Deprecation Notice]

The special `{{fields._slug | localize}}` slug template tag has been deprecated in favor of the configuration above, and will be removed in Sveltia CMS v1.0.0.

:::

## Using Random UUIDs for Slugs

Entry titles and other fields containing non-Latin characters, such as Japanese or Chinese, may not be suitable for generating slugs. To address this issue, Sveltia CMS lets you use random UUIDs as slugs for entries in i18n collections.

This can be achieved by setting the `slug` option with the `{{uuid}}`, `{{uuid_short}}` or `{{uuid_shorter}}` [template tag](/docs/collections/entries/slugs#slug-template-tags) in your collection configuration:

```yaml YAML {5}
collections:
  - name: posts
    label: Blog Posts
    folder: /content/posts
    slug: "{{uuid_short}}"
```

```toml TOML {5}
[[collections]]
name = "posts"
label = "Blog Posts"
folder = "/content/posts"
slug = "{{uuid_short}}"
```

```json JSON {7}
{
  "collections": [
    {
      "name": "posts",
      "label": "Blog Posts",
      "folder": "/content/posts",
      "slug": "{{uuid_short}}"
    }
  ]
}
```

```js JavaScript {7}
{
  collections: [
    {
      name: "posts",
      label: "Blog Posts",
      folder: "/content/posts",
      slug: "{{uuid_short}}",
    },
  ],
}
```

## Preview Paths

When i18n is enabled for an entry collection, you can manage preview paths for each locale using the [`preview_path` option](/docs/collections/entries/previews#preview-paths). This option supports the `{{locale}}` template tag, which will be replaced with the current locale in the preview URL. For example, if you set the `preview_path` to `/{{locale}}/{{slug}}`, the preview URL for an entry with the slug `my-post` in the `fr` locale would be `/fr/my-post`.

The `omit_default_locale_from_preview_path` option can be used to omit the locale code from the preview path for the default locale. For example, if `en` is the default locale and `omit_default_locale_from_preview_path` is set to `true`, the preview URL for the English version of the entry would be `/my-post`, while the preview URL for the French version would still be `/fr/my-post`.

Both options apply to [Deploy Previews](/docs/deployments/previews) as well, so each translation of an unpublished entry links to its own page on the preview build. The per-locale links are offered from the locale pane’s options menu in the Content Editor.
