Project templating tools: Cookiecutter, Yeoman, and Copier

Share this article

Starting a new project can feel like a massive lift, when teams have to follow structures, standards, agreements, include mandatory files, and more. To cut out the tedious legwork, developers turn to project templates — a.k.a. scaffolding, project bootstrap tools, boilerplate generation or skeletons.

The open-source tool Cookiecutter is one of the most popular ways for developers to create templates — and for a good reason. The easy-to-use command-line interface (CLI) allows developers to make customizable templates and generate services from them.

But it’s not the only templating software available. Explore some Cookiecutter alternatives that might be better suited for your project, including Yeoman and Copier. Check out the benefits and disadvantages of Cookiecutter and its alternatives, and which types of projects they might be best suited for, from web apps to microservices.

1. Cookiecutter: The industry standard

Cookiecutter is an easy-to-install command-line utility that allows teams across software engineering, research, data science, and other technical roles to create templates for projects, or use pre-made templates for new projects, such as Python package project templates. It’s cross platform, so it can run on Windows, Mac, and Linux.

You don’t have to know/write Python code to use Cookiecutter, because project templates can generate boilerplate for any programming language or markup format: Python, JavaScript, Ruby, CoffeeScript, RST, Markdown, CSS, HTML, among others. You can even use multiple languages in the same project template. You’ll need some minimal Python knowledge if  you’re creating your own template, as that’s done using Jinja2 templating.

The projects start with a cookiecutter.json file. Then, it opens a {{ cookiecutter.project_name }}/ directory, where project_name is defined in your cookiecutter.json.  After, you can add whatever files/directories you want. You simply have to define your template variables in a cookiecutter.json file. Cookiecutter will ask you a couple of questions to personalize the template — you can choose how to name your project, what the license is, among other decisions, then it generates the skeleton.

It also has features to templatize directory names and filenames. It also supports unlimited levels of directory nesting. Cookiecutter can be used with templates that live in a Git repo, a folder or even a Zip file. It also has plugins such as a pytest plugin, which comes with integrations for the  cookiecutter API.

The benefits of Cookiecutter include its long history, established, active community, and its focus on being config first. It’s stable and configuration-driven, which makes the projects relatively easier to debug than other options. Many queries you might have have likely already been answered (if you go to read the docs), and many templates you might be looking for already exist as examples. You can search for specific and ready-to-use cookiecutter templates in Github search — if you type cookiecutter to find over 4000 related repositories. 

Overall, the ability to create custom templates to fit your and your organization’s needs is incredibly powerful. It allows teams to easily construct new repositories, set testing standards, remember mandatory files like Readme or Changelog, and lower the barriers to entry for new collaborators, from new team members to freelancers to other partners.

2. Yeoman: A new alternative for web apps

Yeoman is a newer templating tool that was originally developed for web apps. It creates scaffolding for web applications and can streamline the development process. The tool runs as a command-line interface (CLI), similar to Cookiecutter. It was used to automate frontend efforts such as creating navigation, headers and footers. It’s now used more commonly for  backend tasks such as creating APIs. It’s open-source and cross-platform, and based on JavaScript. However, it can create applications in any programming language, including Java and C#. 

It’s evolved to be used today for many project functions. It has three tiers, which work independently but support each other. Yeoman’s main offering is a scaffolding tool (called ‘yo’), which templates a new application. In yo, you choose generators, creating a baseline for your application via a Gruntfile. There are many plugins as well to perform various tasks, or you can create your own new plugin to extend yeoman’s functionality even further

In addition, there is a Package Manager used for dependency management —  managing code packages for back-end and front-end development — so that you don’t have to manually download and manage your scripts. Npm, a built-in Node.js-based HTTP development server, and Bower are oft-used options there.

Many Yeoman templates for frontend web-apps include support for linting, testing, minification and much more. These templates also integrate with common tools such as webpack, Babel, TypeScript, React, and Angular.

Its benefits include its many flexible automation use cases such as the ability to programmatically generate files in the template and even write unit tests on the generated files, which helps provide confidence in the templates and ensures developers have a productive and comfortable user experience.

While its customizability and flexibility are benefits, they also can become downsides — more complex templates can become more confusing for developers. Questions of maintaining and testing Yeoman-based projects arise. Setting up your generators and plugins can be time-consuming, although once they’re in place, Yeoman is relatively easy to use for developers. In addition, because it’s newer, not as many pre-made template options exist. Still, its community is growing every day.

3. Copier: An even newer alternative 

Copier is an even newer open-source tool for rendering project templates. It can be installed as a command-line interface, or used as a library directly in your Python code.

Copier has three dimensions: templates, questionnaires, and projects. The template lays out how to generate the subproject, then answers to the questionnaire (configured in the template) are used to generate projects, and then the generated program from the template becomes the project.

All templates allow scaffolding, which gives users a working source code tree. Some templates also allow updating for code lifecycle management, but not all. 

The tool works with local paths and git URL, and you can upload files to work with, as well. It also allows migrations.

Some key benefits of Copier are its modern feel and user experience, that it can allow updates, and that configuration occurs from single or multiple YAML files. 

However, disadvantages include that this tool is newer, so there’s not as large of a community to engage with, or templates to choose from. In addition, it’s under active development, so it’s not as stable as Cookiecutter.

Similarities
& Differences

Programmed in

Python

Output template language

Any desired

Operating system

Windows, MacOS, and Linux

Configuration functions

Default configuration in a JSON file (can cause trouble with dynamic configurations)

Generators

No composable generators

Adding code to existing projects

Hard - you need a new folder with the new things you want added and it will recreate a new project template

Template package format

Git or mercurial repo, Zip file

Templating engine

Jinja

Price

Free, open-source

Similarities and differences between Cookiecutter and Yeoman

Programmed in

Python

Output template language

Any desired

Operating system

Windows, MacOS, and Linux

Configuration functions

Default configuration in a JSON file (can cause trouble with dynamic configurations)

Generators

No composable generators

Adding code to existing projects

Hard - you need a new folder with the new things you want added and it will recreate a new project template

Template package format

Git or mercurial repo, Zip file

Templating engine

Jinja

Price

Free, open-source

Programmed in

Output template language

Operating system

Configuration functions

Generators

Adding code to existing projects

Template package format

Templating engine

Price

Ready to use Cookiecutter?