Skip navigation

Reusing collections of elements with snippets

Content type snippets are reusable collections of content elements, which can be especially useful when defining content types. Content contributors won't see the content type snippets while editing content.

If you ever need to use the same bunch of elements repeatedly in a few content types, you can create a content type snippet to hold those elements. With this approach, you can easily modify the elements from one place.

See how to create snippets inside the app.

Table of contents

    Let's look at an example of using the snippets for SEO metadata.

    Creating content type snippets

    To create a content type snippet for SEO metadata:

    1. From the app menu, choose .
    2. Click the Content type snippets tab.
    3. Click Create new.
    4. Type a name in Content type snippet name.
    5. Drag two Text elements into the element area.
      Tip: You can also add the elements by clicking.
    6. Name the elements Meta keywords and Meta description.
    7. (Optional) Provide guidelines and limitations for each element.
    8. Click Save changes.

    A screenshot of a metadata snippet all set up.

    Note: When defining the snippet, you can use all content elements except for the Content type snippet and URL slug elements.

    Editing codenames

    Codenames are identifiers of objects in Kentico Kontent. A codename is initially generated by the system from the object's name when it is saved for the first time. You can edit codenames by clicking the codename button and then the edit  button. When editing codenames, the new codenames must meet the following conditions:

    • Only lowercase letters, numbers, and underscores are permitted.
    • Codenames must start with a letter or an underscore and have at least one character.
    • Codenames are limited to 60 characters for all objects except multiple choice options, which are limited to 160 characters.
    • Codenames must be unique.

    Adding snippets to content types

    After you create a content type snippet, use it in a content type. Bear in mind that you cannot add a single snippet more than once to prevent duplicate elements.

    To add a Content type snippet element to your content type:

    1. From the app menu, choose .
    2. Open an existing content type.
    3. Drag a Content type snippet element into the element area.
      Tip: You can also add the elements by clicking.
    4. Choose a snippet from the drop-down list.
    5. Save the content type.

    A screenshot of a snippet in a content type.

    Snippets in content items

    In content items themselves, the Content type snippet elements are replaced by the content elements they contain. This makes snippets invisible to content contributors.

    A screenshot of a snippet in a content item.

    What's next?