Seeding Themes

Seeding Themes

Populate blueprints and database records with sample content.

Themes support the ability to import sample content from seed scripts, including database content and Tailor blueprints. A specific folder inside the theme called seeds is used along with a directory structure to provide the content.

# Seeding a Theme

The theme:seed artisan command is used to seed a theme.

php artisan theme:seed <theme name>

You may also use the --root option to instruct the command to import the blueprints in to the root directory instead of in a nested directory.

php artisan theme:seed <theme name> --root

You may also seed a theme using the admin panel by navigating to Settings → Frontend Theme → Manage → Seed Content.

# Directory Structure

Below you can see an example seed directory structure. The blueprints directory contains any blueprint templates used by the theme, these are imported automatically to the app/blueprints directory with a nested directory called mywebsite. The data.yaml file contains instructions on how to import the content in to the database.

├── themes | └── mywebsite | └── seeds ← Theme Seed Directory | ├── blueprints | | └── post.yaml ← Blueprint File | ├── lang | | └── en.json ← Language File | ├── media | | └── banner.jpg ← Media File | ├── data | | ├── blog-posts.json ← Data File | | └── media-files.json | └── data.yaml ← Seeding Script

# Importing Languages

As an optional feature, languages can be imported to the app/lang directory by placing the JSON language files in the lang directory. This makes it possible to translate labels and other descriptions inside blueprints. If a language file already exists in the application language directory, then the language strings will be merged together.

# Importing Data

The data.yaml file contains a specific format used for importing content in to the database. In the example below, two sets of data are imported to the database for Tailor entry content.

-
    name: Blog Post Data
    class: Tailor\Models\RecordImport
    file: seeds/data/blog-posts.json
    attributes:
        file_format: json
        blueprint_uuid: edcd102e-0525-4e4d-b07e-633ae6c18db6
-
    name: Media File Data
    class: Media\Models\MediaLibraryItemImport
    file: seeds/data/media-files.json
    attributes:
        file_format: json

The YAML file should define an array where each item in the array supports the following properties.

Property Description
name gives the import step a name to display to the user.
class refers to a model that extends the interface of Backend\Models\ImportModel.
file refers to the JSON data file that contains the content to import.
attributes a list of attributes to set on the Import Model before importing.

# Tailor Blueprint Data

Use the Tailor\Models\RecordImport class to import Tailor blueprints to the app directory. The following is an example of a JSON file that can be used to import blog categories. Each item in the JSON array produces an imported record in the database with the supplied attributes. Providing an id attribute allows records to link across multiple imports.

[
    {
        "id": 1,
        "title": "Announcements",
        "slug": "announcements"
    },
    {
        "id": 2,
        "title": "News",
        "slug": "news"
    }
]

# Media File Data

Use the Media\Models\MediaLibraryItemImport to import images in to the media directory. The following JSON is an example of importing files to the media library. The rootPath attribute defines a prefix for the media library, this could set to an empty string to import everything in the root directory. The type attribute specifies either file or folder are used to import their respective types, with the path as the destination and source as the source file, found in the context of the theme directory.

[
    {
        "type": "folder",
        "path": "my-theme/announcements",
        "source": "seeds/media/announcements"
    },
    {
        "type": "folder",
        "path": "my-theme/news/2025",
        "source": "seeds/media/news"
    },
    {
        "type": "file",
        "path": "my-theme/banner.jpg",
        "source": "seeds/media/banner.jpg"
    }
]

# Importing Blueprints

Since blueprints do not depend on any specific file or directory structure, they can be moved around freely.

When importing blueprints, simply place the blueprint files in the seeds/blueprints directory. It does not use any configuration, when seeding all blueprints are simply copied to the app/blueprints directory. A new directory is created inside that has the same name as the theme. The blueprints are placed inside this new directory.

Blueprints do not always need to be imported via seeding. They can be included in the theme's /blueprints directory instead. See the introduction article to learn more.