Skip to content

The stack templates command

stack templates

stack templates provides information about how to find templates available for stack new.

Stack provides multiple templates to start a new project from. You can specify one of these templates following your project name in the stack new command:

stack new my-rio-project rio
Downloading template "rio" to create project "my-rio-project" in my-rio-project/ ...
Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- my-rio-project/

Selecting the best among 18 snapshots...

* Matches ...

Selected resolver: ...
Initialising configuration using resolver: ...
Total number of user packages considered: 1
Writing configuration to file: my-rio-project/stack.yaml
All done.
<Stack root>\templates\rio.hsfiles:   10.10 KiB downloaded...

The default templates repository is https://github.com/commercialhaskell/stack-templates. You can download templates from a different GitHub user by prefixing the username and a slash. Command:

stack new my-yesod-project yesodweb/simple

Then template file simple.hsfiles would be downloaded from GitHub repository yesodweb/stack-templates.

You can even download templates from a service other that GitHub, such as GitLab or Bitbucket. For example, command:

stack new my-project gitlab:user29/foo

Template file foo.hsfiles would be downloaded from GitLab, user account user29, repository stack-templates.

If you need more flexibility, you can specify the full URL of the template. Command:

stack new my-project https://my-site.com/content/template9.hsfiles

(The .hsfiles extension is optional; it will be added if it's not specified.)

Alternatively you can use a local template by specifying the path. Command:

stack new project <path_to_template>/template.hsfiles

As a starting point for creating your own templates, you can use the "simple" template. The stack-templates repository provides an introduction into creating templates.