Skip to main content
Version: 1.23-dev

Template Repositories

Since Gitea 1.11, you can create template repositories. When creating a repo based on a template, you can copy most of its content, and even auto-inject variables into it.

By default, variables will not be expanded in any file. Only files contained in a pattern inside the .gitea/template file will be checked for if they contain variables. When creating the template, all files are included except for this .gitea/template file.

Gitea uses gobwas/glob for its glob syntax. It closely resembles a traditional .gitignore, however there may be slight differences.

Example .gitea/template file

All paths are relative to the base of the repository

# Expand all .go files, anywhere in the repository
**.go

# All text files in the text directory
text/*.txt

# A specific file
a/b/c/d.json

# Batch files in both upper or lower case can be matched
**.[bB][aA][tT]

Variable Expansion

In any file matched by the above globs, the variables below will be expanded.

Matching filenames and paths can also be expanded, and are conservatively sanitized to support cross-platform filesystems.

You can use variables by prefixing them with $ or surrounding them with ${}, so both $VAR and ${VAR} insert the value of VAR at this location. To escape an expansion, use $$, such as $$VAR or $${VAR}.

These are the variables Gitea currently recognizes:

VariableExpands ToTransformable
YEARThe year of generating the repository (i.e. 2024)
MONTHThe month of generating the repository (i.e. 03)
MONTH_ENGLISHThe month but in English (i.e. March)
DAYThe day of generating the repository (i.e. 02)
REPO_NAMEThe name of the generated repository
TEMPLATE_NAMEThe name of the template repository
REPO_DESCRIPTIONThe description of the generated repository
TEMPLATE_DESCRIPTIONThe description of the template repository
REPO_OWNERThe owner of the generated repository
TEMPLATE_OWNERThe owner of the template repository
REPO_LINKThe URL to the generated repository
TEMPLATE_LINKThe URL to the template repository
REPO_HTTPS_URLThe HTTP(S) clone link for the generated repository
TEMPLATE_HTTPS_URLThe HTTP(S) clone link for the template repository
REPO_SSH_URLThe SSH clone link for the generated repository
TEMPLATE_SSH_URLThe SSH clone link for the template repository

Transformers 🤖

Since Gitea 1.12.0, variables marked as transformable in the table above also have alternative versions where the given transformer has been applied.

Transformed variables can be called by appending the transformer name to the variable name. For example, to get REPO_NAME in PASCAL-case, you should use the variable ${REPO_NAME_PASCAL}.

The following transformers are available (assuming go-sdk is the input):

TransformerEffect
SNAKEgo_sdk
KEBABgo-sdk
CAMELgoSdk
PASCALGoSdk
LOWERgo-sdk
UPPERGO-SDK
TITLEGo-Sdk