Skip to main content
Version: v4.5.0

Create a Template

Before you begin

Templates define a basic structure of a project and is the starting point for creating an application.

The template defines basic aspects, such as programming language, build system, packaging, frameworks, and structural components.

STK CLI creates a Template structure for you to edit and customize, then publish and share with others.

Creating a Template

There are two ways to create a Template:

  1. You can create directly in the Stack folder.
  2. Create the local Template already linked to a repository.

This tutorial shows the second option. For more details about the first option, see Create Stack page.

Step 1. Create an empty repository to store the Template

The repository is the basis to store your Template.

  • You can create on any Git code hosting platform (GitHub or GitLab).
  • It can be public or private.
  • You need to have access to the repository and your credentials must be configured locally on your machine.

Step 2. Create your Template structure

Run the command below and use the repository URL created in Step 1:

stk-legacy create template --remote <url_of_repository>

In this case, the Template name will be the repository's name you inserted.

STK CLI does all the configuration to use the repository given as a parameter. You only need to upload the code generated at the end of the Template creation.

It is optional to use another name for the Template even if you link it to a GitHub repository. If you want to do it, use the parameters -R or --remote and the NAME. Check out the example: `stk-legacy create template --remote <url_repository_git> <my_template_name>``.

Step 3. Confirm if you created the Template structure

The Template was created locally.

Check on your computer if a folder was created with the same name as the repository given as a parameter in Step 2.

This folder must have:

  1. A template.yaml file to define information about the Template and its input data.
  2. A templates folder, that has a README.md with Template customization instructions.

Why are Template inputs necessary?

You can customize some settings, and with these inputs, you will get information from your Template's users to create your projects and applications.

For more information about configuring your `template.yaml`` and its inputs, see Template's page.

For more information on how to customize your Template, see Template Examples page.

Step 4. Upload Template to your code hosting platform

Your Template still is only local. To make it accessible on GitHub, run the commands:

Go to Template's folder and run the command:

git add .

Depois:

git commit -m “message”

And finish:

git push origin main

Step 5. Add Template to a Stack

Click here if you have not yet created an empty Stack:

If you haven't created a Stack yet, run the command:

stk-legacy create stack <name-of-stack-to-be-created>

The first question on the terminal is about the Stack description.

It is optional to associate a repository's URL when creating a Stack. If you want to do it, don't name it, run the command with the argument-R or --remote. Check out the example: stk-legacy create stack --remote <url-repository-git>


Add a Template to your Stack, so you can use it in your project:

  1. Go to the Stack folder:
cd <stack-name>
  1. Use your repository URL and run the command:
stk-legacy add template <your-template-repo-url>

Done! You added your Template to a Stack.

info

Templates and Plugins are used to create an application (app). To test them, use the command stk-legacy create app and stk-legacy apply plugin adding the folder path of the Template or Plugin you want to test.

Was this page helpful?