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:
- You can create directly in the Stack folder.
- 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 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
NAME. Check out the example: `stk 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:
template.yamlfile to define information about the Template and its input data.
- 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 .
git commit -m “message”
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 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
--remote. Check out the example:
stk create stack --remote <url-repository-git>
Add a Template to your Stack, so you can use it in your project:
- Go to the Stack folder:
- Use your repository URL and run the command:
stk add template <your-template-repo-url>
Done! You added your Template to a Stack.
Templates and Plugins are used to create an application (app). To test them, use the command
stk create app and
stk apply plugin adding the folder path of the Template or Plugin you want to test.
Was this page helpful?