Templates are pre-made Strapi configurations designed for specific use cases. They allow bootstrapping a custom Strapi application. A template can configure collection types and single types, components and dynamic zones, and plugins.
- A template is only useful once applied on top of a default Strapi application via the CLI. It is not a configured application and cannot be run on its own since it lacks many files (e.g. database configurations,
- A starter is a pre-made frontend application that consumes a Strapi API.
Using a template
To create a new Strapi project based on a template, run the following command:
yarn create strapi-app my-project --template <template-package>
npx create-strapi-app@latest my-project --template <template-package>
npm is used to install template packages, so
<template-package> can match any format supported by
npm install. This includes npm packages, scoped packages, packages with a precise version or tag, and local directories for development.
For convenience, official Strapi templates also have a shorthand, making it possible to omit the
@strapi/template- prefix from the template npm package name:
# use the full template name
yarn create strapi-app my-project --template @strapi/template-blog
# use the shorthand
yarn create strapi-app my-project --template blog
--template option can be used in combination with all other
create-strapi-app options (e.g.
Creating a template
Templates are generated from a customized Strapi application and published to the npm package registry. Before creating a template make sure you have a Strapi application that matches your use case and that you have read the template requirements.
Keep the following requirements in mind when creating a template:
Templates should not deal with environment-specific configurations (e.g. databases or upload and email providers). This keeps templates maintainable and avoids conflicts with other CLI options (e.g.
Templates must follow a specific file structure, containing the following at the repository's root:
This structure can be created manually or automatically generated with the
strapi templates:generate command:
yarn strapi templates:generate <path>
The repository root can contain any other files or directories desired, but must include the
package.json file, and
template.json file at a minimum.
template directory is used to extend the file contents of a Strapi project and should only include the files that will overwrite the default Strapi application.
Only the following contents are allowed inside the
README.md: the readme of an application made with this template
.env.exampleto specify required environment variables
data/to store the data imported by a seed script
public/to serve files
scripts/for custom scripts
If any unexpected file or directory is found, the installation will crash.
template.json is used to extend the Strapi application's default
package.json. All properties overwriting the default
package.json should be included in a root
"custom": "node ./scripts/custom.js"
Packaging and publishing
With the above requirements in mind, follow these steps to create and publish a template:
- Create a standard Strapi application with
create-strapi-app, using the
- Customize your application to match the needs of your use case.
- Generate your template using the CLI by running
strapi templates:generate <path>
- Navigate to this path to see your generated template.
- If you have modified your application's
package.json, include these changes (and only these changes) in
packageproperty. If not, leave it as an empty object.
npm publishto make your template available on the npm package registry.
Strapi-maintained templates and community-maintained templates can be found on GitHub.