Creating SEO-friendly URLs
Learn how to generate URL slugs from Text elements to customize your URLs.The URL slug element specifies an SEO-friendly text that you can use in the URLs of your content items. The element automatically generates its value based on the Text content element of your choice, unless you change the element's value manually. You can use the element only once in a content type.
Table of contents
Because the URL slug element can generate its value from any Text element, you can use a different URL slug for each language variant of your content items.
Note that you can no longer choose to generate new URL slugs from content item name. When updating a URL slug element that still uses the content item name to generate its value, you can choose a Text element instead. By doing so, you will no longer be able to switch back to the content item name.
Let’s look at an example of using URL slug in a content type.
Adding URL slug to content types
To add a URL slug to an existing content type:
- From the app menu, choose Content models.
- Open the Article content type for editing.
- Add the URL slug element to the content type.
- Type a name of the URL slug element. For example, you can label it "Page URL".
- Click Show configuration
- Select a Text element from the drop-down list to generate URL slug.
- Click Save changes.
The drop-down list shows you all text elements from the current content type and from any content type snippets that are included in the content type.
If there isn't any Text element to choose from, you need to add one first.
The URL slug's length is limited only by the maximum length of the dependent text element. Keep in mind that the limitation for the URL in web browsers is usually 2,000 characters.
URL slug in content items
In content items, your content contributors will see the URL slug element like this:
In the bottom right corner of the URL slug (URL pattern in the image), you can see which text element generates the URL slug and how many characters it has.
The URL slug value is auto-generated from the Text element. This generation follows two simple rules:
- All letters are made lowercase.
- Any sequence of special characters other than dashes (-) with be replaced by a dash to prevent problems when used in the URL.
You can also customize the URL slug value to suit your needs, which causes the element to switch to manual mode. As a result, the URL slug will no longer react to changes made to the dependent text element.
Multiple content items can have the same URL slug
Kentico Kontent doesn't check if the URL slug values in your content items are unique across your project. This means you can have multiple content items with the same URL slug value.
Deleting dependent Text elements
When deleting a Text element that is currently used to generate URL slug, there are two options depending on the location of the Text element:
- In content types, you'll be able to delete the dependent Text element. After deleting the element, you'll be asked to choose a different Text element before saving the changes. If you don’t have a Text element in the current content type, you’ll need to create a new one.
- In content type snippets, you won't be able to delete a dependent Text element. First you need to choose a different Text element to generate URL slug by changing it directly in the content type. After that, you can come back to delete the Text element in the content type snippet.
Element removal cannot be undone
This action is irreversible. Removing an element from a content type or content type snippet removes the element across all content items based on that content type or snippet.